Skip to content

fix(merge): gate commit-append separately so declining it keeps hooks#2802

Merged
max-sixty merged 1 commit into
mainfrom
project-commit
May 18, 2026
Merged

fix(merge): gate commit-append separately so declining it keeps hooks#2802
max-sixty merged 1 commit into
mainfrom
project-commit

Conversation

@max-sixty
Copy link
Copy Markdown
Owner

Summary

wt merge bundled the project commit-append into the hook-approval batch and shadowed verify = false on any decline. When the project hooks were already approved (and thus filtered out of the prompt), declining the lone commit-append prompt skipped every pre-merge/post-merge hook for that run — even though the user only meant to skip the append. This was flagged as a follow-up during review of #2774.

The append is now resolved through the shared approve_commit_template_append gate — the same path wt step commit / wt step squash already use — so its decline drops only the append and never touches hook approval. Hooks are approved on their own; only a hook decline skips hooks.

Trade-off: when both project hooks and the append are unapproved on a fresh repo, the user now sees two prompts instead of one bundled prompt. This matches the standalone commit/squash flow and is the canonical behavior; the old single-prompt bundling was what introduced the conflation. Already-approved appends still don't re-prompt.

Also in this PR

  • Message canonicalizationmerge, removal, prune, and switch now print Commands declined, … without hooks, matching the wording step squash / step commit already used. wt hook and wt config approvals add stay bare (they end on decline rather than continuing an operation).
  • Docs — the hook Security section now states that declining skips every project command for that operation (already-approved ones included) and that saved approvals are unaffected. Synced to the skill reference.
  • Doc-comment fixesHookGate / PreApprovedGuidance comments no longer describe the removed bundled-prompt flow.

Testing

  • New regression test test_merge_decline_append_keeps_approved_hooks: with the hook pre-approved, declining the append still runs the pre-commit hook and the merge succeeds (fails on the old code, passes now).
  • test_merge_bundles_append_into_hook_approval renamed to test_merge_prompts_hooks_and_append_separately, updated for the two-prompt flow.
  • Four decline snapshots regenerated (message text only).
  • Full pre-merge gate green: 3736 tests, clippy, fmt, doc-sync.

`wt merge` bundled the project commit-append into the hook-approval
batch and shadowed `verify = false` on any decline. When hooks were
already approved (filtered out of the prompt), declining the lone
commit-append prompt skipped every pre-merge/post-merge hook for that
run. Resolve the append through the shared
`approve_commit_template_append` gate instead — the same path
`wt step commit`/`squash` use — so its decline drops only the append
and never touches hook approval.

Also:
- Canonicalize the "Commands declined, …" messages: merge, removal,
  prune, and switch now say "… without hooks", matching the existing
  squash/commit wording (the operation continues; only project hooks
  are skipped). `wt hook` / `wt config approvals add` stay bare — they
  end on decline rather than continuing an operation.
- Document the decline behavior in the hook Security section:
  declining skips every project command for that operation, including
  already-approved ones; saved approvals are unaffected.
- Correct HookGate / PreApprovedGuidance doc comments that still
  described the old bundled-prompt flow.

Adds a regression test (test_merge_decline_append_keeps_approved_hooks)
and renames the bundling test to describe the corrected two-prompt flow.

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 7d09c5d into main May 18, 2026
34 checks passed
@max-sixty max-sixty deleted the project-commit branch May 18, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants