git-gohooks/githook-gotest/hook.go
2022-05-20 21:42:53 +02:00

26 lines
420 B
Go

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