[main] fixed some directory hazzle
This commit is contained in:
parent
b47aa0d903
commit
17a18be8a5
8
main.go
8
main.go
|
@ -3,19 +3,23 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mthie/git-gohooks/general"
|
"github.com/mthie/git-gohooks/general"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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], "/")
|
currentFileSplit := strings.Split(os.Args[0], "/")
|
||||||
currentFile := currentFileSplit[len(currentFileSplit)-1]
|
currentFile := currentFileSplit[len(currentFileSplit)-1]
|
||||||
files := general.GetFilesList()
|
files := general.GetFilesList()
|
||||||
|
os.Chdir(gitroot)
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if strings.HasPrefix(file, fmt.Sprintf("%s_", currentFile)) {
|
if strings.HasPrefix(file, fmt.Sprintf("%s_", currentFile)) {
|
||||||
result, errCode := general.RunCommand("./" + file)
|
result, errCode := general.RunCommand(gitroot + "/.git/hooks/" + file)
|
||||||
if errCode != 0 {
|
if errCode != 0 {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %s", result)
|
fmt.Fprintf(os.Stderr, "Error: %s", result)
|
||||||
os.Exit(errCode)
|
os.Exit(errCode)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user