diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit new file mode 100755 index 00000000..afe860ea --- /dev/null +++ b/.git-hooks/pre-commit @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Pre-commit hook installed by huskies. +# Runs script/check (fmt-check, clippy, cargo check, source-map-check) +# before every commit. Aborts if any gate fails. +# +# Emergency bypass: git commit --no-verify (see AGENT.md — avoid this) + +REPO_ROOT="$(git rev-parse --show-toplevel)" + +printf '[pre-commit] Running script/check ...\n' +OUTPUT=$("$REPO_ROOT/script/check" 2>&1) +STATUS=$? + +if [ "$STATUS" -ne 0 ]; then +printf '\n=== PRE-COMMIT HOOK FAILED ===\n\n' +printf '%s\n' "$OUTPUT" +printf '\nFix the issues above, then re-validate with:\n' +printf ' script/check\n' +printf '\nEmergency bypass (see AGENT.md -- avoid this):\n' +printf ' git commit --no-verify\n\n' +exit 1 +fi