[gobuild] initial hook to check the build
This commit is contained in:
parent
e30a499eec
commit
33fdadb05f
26
githook-gobuild/hook.go
Normal file
26
githook-gobuild/hook.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
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", "build", ".", "./...")
|
||||
if status != 0 {
|
||||
fmt.Fprint(os.Stderr, "Build failed, please commit only stuff that builds.\n")
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
general.RunCommand("go", "clean", ".", "./...")
|
||||
}
|
Loading…
Reference in New Issue
Block a user