Skip to content

fix: collect pre-commit hooks when squashing on clean worktree#695

Merged
max-sixty merged 4 commits intomainfrom
fix/precommit-squash-approval
Jan 24, 2026
Merged

fix: collect pre-commit hooks when squashing on clean worktree#695
max-sixty merged 4 commits intomainfrom
fix/precommit-squash-approval

Conversation

@max-sixty
Copy link
Copy Markdown
Owner

Summary

Fixes pre-commit hooks bypassing the approval system when squashing on a clean worktree.

The problem: collect_merge_commands() only collected pre-commit hooks when the worktree was dirty. However, wt merge --squash on a clean worktree with multiple commits still creates a new commit (the squashed result), so pre-commit hooks should run.

The fix: Added squash_enabled parameter to collect_merge_commands(). Pre-commit hooks are now collected when either the worktree is dirty OR squash is enabled, ensuring they go through the approval flow.

Changes

  • Modified collect_merge_commands() in src/commands/merge.rs to accept squash_enabled parameter
  • Added will_create_commit variable for clarity
  • Added test test_merge_pre_commit_collected_for_squash_clean_worktree

Test plan

  • All existing tests pass
  • New test verifies pre-commit hooks are collected for squash on clean worktree

🤖 Generated with Claude Code

max-sixty and others added 3 commits January 16, 2026 15:13
`collect_merge_commands()` only collected pre-commit hooks when the worktree
was dirty, but squash operations can create commits even on clean worktrees.
Added `squash_enabled` parameter so pre-commit hooks are collected for approval
when either the worktree is dirty OR squash is enabled.

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty enabled auto-merge (squash) January 24, 2026 01:19
@max-sixty
Copy link
Copy Markdown
Owner Author

@claude resolve conflicts

@worktrunk-bot
Copy link
Copy Markdown
Collaborator

worktrunk-bot commented Jan 24, 2026

Claude finished @max-sixty's task in 4m 30s —— View job


Resolving merge conflicts ✅

  • Check current branch state and fetch latest changes
  • Identify conflicting files
  • Resolve conflicts (auto-merged successfully!)
  • Run tests to verify resolution
  • Commit and push resolved changes

The merge with origin/main completed successfully with no conflicts. Git auto-merged 32 files including documentation, config handling, and snapshot tests.

Verification:

  • ✅ All 2,131 tests passed
  • ✅ Clippy checks passed
  • ✅ Code formatting verified

Result: The merge commit has been pushed to the PR branch. The PR is now up-to-date with main and ready for review.

--- • Branch: fix/precommit-squash-approval

@max-sixty max-sixty merged commit e5e373d into main Jan 24, 2026
21 checks passed
@max-sixty max-sixty deleted the fix/precommit-squash-approval branch January 24, 2026 16:34
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