From 17a18be8a5e060862a1b884948f6ed2c57c6a9c1 Mon Sep 17 00:00:00 2001 From: Martin Thielecke Date: Sat, 1 Aug 2015 01:16:17 +0000 Subject: [PATCH] [main] fixed some directory hazzle --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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)