[main] fixed some directory hazzle

This commit is contained in:
Martin Thielecke 2015-08-01 01:16:17 +00:00
parent b47aa0d903
commit 17a18be8a5

View File

@ -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)