54 lines
1.8 KiB
Bash
Executable file
54 lines
1.8 KiB
Bash
Executable file
#!/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
|
|
# time, so it catches every path: per-worktree `user.name`, exported
|
|
# GIT_AUTHOR_NAME / GIT_COMMITTER_NAME, and the legacy shared-clone
|
|
# approach. See docs/internal/MULTITENANT-AGENT-WORKFLOW.md.
|
|
AUTHOR_IDENT=$(git var GIT_AUTHOR_IDENT 2>/dev/null || true)
|
|
COMMITTER_IDENT=$(git var GIT_COMMITTER_IDENT 2>/dev/null || true)
|
|
# Strip " <email> timestamp tz" off each ident to get just the name.
|
|
AUTHOR_NAME=${AUTHOR_IDENT% <*}
|
|
COMMITTER_NAME=${COMMITTER_IDENT% <*}
|
|
|
|
guard_ident() {
|
|
role=$1
|
|
name=$2
|
|
case "$name" in
|
|
"Operator & "*|"Clawdie AI") ;;
|
|
*)
|
|
echo "pre-commit: $role name is '$name' — expected 'Operator & <agent>'." >&2
|
|
echo " Fix: use a per-agent worktree with" >&2
|
|
echo " git config --worktree user.name \"Operator & <agent>\"" >&2
|
|
echo " Or export GIT_AUTHOR_NAME and GIT_COMMITTER_NAME for this shell." >&2
|
|
echo " See docs/internal/MULTITENANT-AGENT-WORKFLOW.md." >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
guard_ident author "$AUTHOR_NAME"
|
|
guard_ident committer "$COMMITTER_NAME"
|
|
|
|
node scripts/update-readme-version.mjs
|
|
git add README.md
|