diff --git a/main.go b/main.go index 2ff0f7e..e7c64d2 100644 --- a/main.go +++ b/main.go @@ -3,19 +3,23 @@ package main import ( "fmt" "os" + "path/filepath" "strings" "github.com/mthie/git-gohooks/general" ) func main() { - os.Chdir(general.GetGitRoot() + "/.git/hooks") + gitroot, _ := filepath.Abs(filepath.Dir(general.GetGitRoot())) + os.Chdir(gitroot + "/.git/hooks") currentFileSplit := strings.Split(os.Args[0], "/") currentFile := currentFileSplit[len(currentFileSplit)-1] files := general.GetFilesList() + os.Chdir(gitroot) + for _, file := range files { if strings.HasPrefix(file, fmt.Sprintf("%s_", currentFile)) { - result, errCode := general.RunCommand("./" + file) + result, errCode := general.RunCommand(gitroot + "/.git/hooks/" + file) if errCode != 0 { fmt.Fprintf(os.Stderr, "Error: %s", result) os.Exit(errCode)