2015-08-01 02:31:03 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2015-08-01 03:16:17 +02:00
|
|
|
"path/filepath"
|
2015-08-01 02:31:03 +02:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/mthie/git-gohooks/general"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-08-01 03:16:17 +02:00
|
|
|
gitroot, _ := filepath.Abs(filepath.Dir(general.GetGitRoot()))
|
|
|
|
os.Chdir(gitroot + "/.git/hooks")
|
2015-08-01 02:31:03 +02:00
|
|
|
currentFileSplit := strings.Split(os.Args[0], "/")
|
|
|
|
currentFile := currentFileSplit[len(currentFileSplit)-1]
|
|
|
|
files := general.GetFilesList()
|
2015-08-01 03:16:17 +02:00
|
|
|
os.Chdir(gitroot)
|
|
|
|
|
2015-08-01 02:31:03 +02:00
|
|
|
for _, file := range files {
|
|
|
|
if strings.HasPrefix(file, fmt.Sprintf("%s_", currentFile)) {
|
2015-08-01 03:16:17 +02:00
|
|
|
result, errCode := general.RunCommand(gitroot + "/.git/hooks/" + file)
|
2015-08-01 02:31:03 +02:00
|
|
|
if errCode != 0 {
|
|
|
|
fmt.Fprintf(os.Stderr, "Error: %s", result)
|
|
|
|
os.Exit(errCode)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|