Commit 50ae1abed1fe
Changed files (1)
tools
claude-hooks
cmd
validate-git-push
tools/claude-hooks/cmd/validate-git-push/main.go
@@ -80,16 +80,16 @@ func main() {
// Check if it has explicit refspec
if !hasExplicitRefspec(command) {
- // Block the command - output error message and exit non-zero
- fmt.Println("BLOCKED: git push without explicit refspec detected!")
- fmt.Println("")
- fmt.Println("The command uses implicit branch tracking which can push to wrong branches.")
- fmt.Println("")
- fmt.Println("Use explicit refspec instead:")
- fmt.Println(" git push origin <branch>:<branch>")
- fmt.Println(" git push origin HEAD:<branch>")
- fmt.Println("")
- fmt.Printf("Blocked command: %s\n", command)
+ // Block the command - output error message to stderr and exit non-zero
+ fmt.Fprintln(os.Stderr, "BLOCKED: git push without explicit refspec detected!")
+ fmt.Fprintln(os.Stderr, "")
+ fmt.Fprintln(os.Stderr, "The command uses implicit branch tracking which can push to wrong branches.")
+ fmt.Fprintln(os.Stderr, "")
+ fmt.Fprintln(os.Stderr, "Use explicit refspec instead:")
+ fmt.Fprintln(os.Stderr, " git push origin <branch>:<branch>")
+ fmt.Fprintln(os.Stderr, " git push origin HEAD:<branch>")
+ fmt.Fprintln(os.Stderr, "")
+ fmt.Fprintf(os.Stderr, "Blocked command: %s\n", command)
os.Exit(2) // Non-zero exit blocks the tool
}