git-pre-commit-hook/main.go

40 lines
568 B
Go

package main
import (
"fmt"
"os"
)
func main() {
if blacklisted() || !hasGo() {
os.Exit(0)
}
var exitCode int
Info("Stashing unstaged changes…")
gitStashPush()
Info("Checking for large files…")
if err := checkLargeFiles(); err != nil {
fmt.Println(err)
exitCode = 1
}
Info("Running goimports…")
if err := goFmt(); err != nil {
fmt.Println(err)
exitCode = 1
}
Info("Running go vet…")
if err := goVet(); err != nil {
fmt.Println(err)
exitCode = 1
}
Info("Restoring unstaged changes…")
gitStashPop()
os.Exit(exitCode)
}