Repository navigation
fix(hooks): sync after rebase and diagnose disabled git hooks - #983
Conversation
|
No findings. The PR description documents sufficient testing, including a representative real-CLI/e2e verification at head commit |
9cdd4f2 to
b801e39
Compare
The PR description otherwise documents sufficient testing, including representative real-CLI verification. |
|
Re the [P1] on Correction: an earlier version of this comment said no hook fires in that case. That was wrong: rebase discards successful hook output, and my probe read output. Logging hooks to a file shows
Git 2.14 to 2.32 skipped pull's Fix: on |
The earlier fast-forward rebase finding is resolved by the documented Git 2.32-and-older autostash limitation. The PR description includes sufficient representative real-CLI testing; the final commit is documentation-only. |
…ckout Git 2.14-2.32 runs a fast-forward git pull --rebase with autostash as a rebase that only checks out the upstream: no post-merge, no post-rewrite. The post-checkout handler only accepted new worktrees, so nothing synced. Route a post-checkout whose GIT_REFLOG_ACTION is a pull or rebase and whose old HEAD is an ancestor of the new one through the git-pull sync. Divergent rebases fail the ancestry check and keep syncing once, on post-rewrite.
A hook disabled with git config --worktree stays disabled after git config --local <key> true, because worktree config wins. gitHookStatus now records the scope of the effective setting, and the advice unsets the worktree value, keeps the local override for local/global/system, and names any other scope.
89132ea to
9a24dd0
Compare
|
No findings.
|
Summary
Rebase reuses the existing capped inline pull and detached retry. Amend does not sync; pull preserves explicit disable settings. The fast-forward path adds no hook: it reuses the installed
post-checkout.Type of Change
Evidence
Before: the built-CLI divergent-rebase regression exited 0 but failed with a missing delivered rule. A named hook set to
enabled=falsestill returnedinstalled: true.After: real Git/CLI checks deliver resources before merge and rebase return, deliver only after conflict resolution, ignore amend, and diagnose disabled hooks. Reactivation restores new-worktree delivery; pull keeps
enabled=false.Legacy Git, real teamai through the installed
.git/hooksscripts (Docker,node:20-alpinewith upstream Git 2.32.7 and 2.26.3 built from source; self mode; same results on both versions):b801e39f9a24dd0dpull --rebase,rebase.autoStash=true, dirty treepull --rebase --autostash, dirty treepull --rebase, no autostashpull --rebase --autostashrebase --continuegit checkout --detach origin/mainTest Plan
npx tsc --noEmitnpm run lintnpx vitest run: 8,107 passed, 20 skipped; 392 test files passed, 1 skipped.hook-handlers.test.ts: four sync cases failed before the fix; divergent, non-pull action, unknown action, file checkout, unchanged HEAD and non-OID args stay skipped) and e2elegacy-autostash-fast-forward(runs the rebase step under the pull'sGIT_REFLOG_ACTIONas Git <= 2.32 does; failed with the rule undelivered, passes now). E2Eautostash-fast-forwardguards the Git 2.33+post-mergepath.git-hook.test.tsdisables withgit config --worktreeand expectsgit config --worktree --unset <key>; a command-scope case expects "unset or override it there".npm run buildnpx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/git-hook-new-worktree.test.ts --retry 0: 34 passed at9a24dd0dwith Git 2.55, local Git remotes and isolated HOME. Covers merge/rebase, configured rebase, conflict continuation, fast-forward autostash rebase, amend, disabled diagnostics/reactivation, lock failure records and uninstall.git diff --checkExtra providers and agent coverage are left to CI. English/Chinese usage guides and affected skill-data are synchronized.
Related Issues
No linked issue.
Merge Danger
Door: two-way
Revert the code. For projects that already pulled this version, also remove
hook.teamai-post-rewritefrom local Git config; on older Git remove only its TeamAI-marked block from.git/hooks/post-rewrite. Preserve the owner's script. Normal uninstall removes the new hook too.Blast Radius: hooks
Project Git synchronization and its doctor check. Named disable settings require Git 2.54+; event disable settings require Git 2.55+. Existing hook managers and explicit disable settings are preserved.
Notes for Reviewers
The new event uses existing install/remove loops and the same synchronization handler. Review the rebase-only guard, effective activation check and preservation of other hooks.
Codex review [P1] (fast-forward
pull --rebasefires neither hook) is valid for Git 2.14–2.32 with autostash: those versions skip themerge --ff-onlyshortcut (git/git f15e7cf5cc, reverted by 340062243a in 2.33) and run a rebase that only checks out the upstream, so onlypost-checkoutfires, with a non-zero old OID that the new-worktree handler ignored. Fixed without adding a hook: the git-pull handler also takespost-checkoutwhen the branch flag is 1, both OIDs are real and differ,GIT_REFLOG_ACTIONstarts withpullorrebase, andgit merge-base --is-ancestor old newsucceeds. It keeps the git-pull fetch/lock caps and self-mode gate, and records failures aspost-checkout. Divergent rebases fail the ancestry check and keep syncing once onpost-rewrite; an unknown reflog action skips. Git 2.33+ still syncs fast-forwards onpost-merge.Codex review [P3] (worktree-scope disable):
git config --local <key> truecannot overridegit config --worktree <key> false.gitHookStatusnow records the effective setting's scope (git config --show-scope --get), and doctor advisesgit config --worktree --unset <key>for worktree scope, keeps the local override for local/global/system, and names any other scope.