[main] added wrapper to execute all files with the filename as suffix

This commit is contained in:
Martin Thielecke 2015-08-01 00:31:03 +00:00
parent f4272325e7
commit a2775e8435

26
main.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"fmt"
"os"
"strings"
"github.com/mthie/git-gohooks/general"
)
func main() {
os.Chdir(general.GetGitRoot() + "/.git/hooks")
currentFileSplit := strings.Split(os.Args[0], "/")
currentFile := currentFileSplit[len(currentFileSplit)-1]
files := general.GetFilesList()
for _, file := range files {
if strings.HasPrefix(file, fmt.Sprintf("%s_", currentFile)) {
result, errCode := general.RunCommand("./" + file)
if errCode != 0 {
fmt.Fprintf(os.Stderr, "Error: %s", result)
os.Exit(errCode)
return
}
}
}
}