Auto-heal shared git config drift in hooks

---
Build: pass | Tests: pass — Tests  2044 passed (2044)
This commit is contained in:
Operator & Codex 2026-04-29 09:50:38 +02:00
parent c46786d2f4
commit 9c362251e6
2 changed files with 37 additions and 0 deletions

View file

@ -1,4 +1,24 @@
#!/bin/sh
set -eu
# Auto-heal shared git config drift before any commit-time git plumbing.
# git-doctor returns:
# 0 healthy
# 1 broken/unfixable
# 2 fixed with --fix
DOCTOR_STATUS=0
sh scripts/git-doctor.sh --fix || DOCTOR_STATUS=$?
case "$DOCTOR_STATUS" in
0) ;;
2)
echo "pre-commit: repaired shared git config drift via git-doctor" >&2
;;
*)
echo "pre-commit: git-doctor reported an unhealed repository problem" >&2
exit "$DOCTOR_STATUS"
;;
esac
# Attribution guard: validate the effective author and committer identity
# git will actually record, not just .git/config. Resolves env vars →
# worktree config → global config in the same order git uses at commit

17
hooks/pre-push Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh
set -eu
# Catch/repair shared git config drift before remote operations.
DOCTOR_STATUS=0
sh scripts/git-doctor.sh --fix || DOCTOR_STATUS=$?
case "$DOCTOR_STATUS" in
0) exit 0 ;;
2)
echo "pre-push: repaired shared git config drift via git-doctor" >&2
exit 0
;;
*)
echo "pre-push: git-doctor reported an unhealed repository problem" >&2
exit "$DOCTOR_STATUS"
;;
esac