[gotest] new hook for go test and added binary to gitignore

This commit is contained in:
Martin Thielecke 2015-07-31 23:58:20 +00:00
parent 4cac9210a6
commit d8181277e6
2 changed files with 26 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
githook-gofmt/githook-gofmt
githook-gobuild/githook-gobuild
githook-gotest/githook-gotest

25
githook-gotest/hook.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"fmt"
"os"
"github.com/mthie/git-gohooks/general"
)
func main() {
files := general.GetChangedGoFiles()
if files == nil {
os.Exit(0)
return
}
os.Chdir(general.GetGitRoot())
_, status := general.RunCommand("go", "test", "-test.short", "./...")
if status != 0 {
fmt.Fprint(os.Stderr, "Test failed, please commit only stuff that works.\n")
os.Exit(1)
return
}
}