[gotest] new hook for go test and added binary to gitignore
This commit is contained in:
parent
4cac9210a6
commit
d8181277e6
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
githook-gofmt/githook-gofmt
|
||||
githook-gobuild/githook-gobuild
|
||||
githook-gotest/githook-gotest
|
||||
|
|
25
githook-gotest/hook.go
Normal file
25
githook-gotest/hook.go
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user