Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor(merge): Run pre-merge hook after rebase
Maximilian Roos070fa5fc2097
diff --git a/README.md b/README.mdindex 78f6c0de5..9c736cda8 100644--- a/README.md+++ b/README.md@@ -266,7 +266,7 @@ Automate common tasks by creating `.config/wt.toml` in your repository root. Run| **post-start-command** | After post-create completes | Parallel, non-blocking (background processes) | Logs warning, doesn't affect switch result || **pre-commit-command** | Before committing changes during `wt merge` (when not squashing) | Sequential, blocking, fail-fast | Terminates merge immediately || **pre-squash-command** | Before squashing commits during `wt merge --squash` | Sequential, blocking, fail-fast | Terminates merge immediately |-| **pre-merge-command** | Before any commits/rebasing during `wt merge` | Sequential, blocking, fail-fast | Terminates merge immediately |+| **pre-merge-command** | After rebase completes during `wt merge` (validates rebased state before push) | Sequential, blocking, fail-fast | Terminates merge immediately || **post-merge-command** | After successful merge and push to target branch, before cleanup | Sequential, blocking | Logs warning, continues with remaining commands |**Template variables:** `{repo}`, `{branch}`, `{worktree}`, `{repo_root}`, `{target}`diff --git a/src/main.rs b/src/main.rsindex aaa201822..67035dbb4 100644--- a/src/main.rs+++ b/src/main.rs@@ -225,22 +225,23 @@ The merge operation follows a strict order designed for fail-fast execution:Verifies current branch exists (not detached HEAD) and determines target branch(defaults to repository's default branch).-2. Run pre-merge commands- Runs commands from project config's [pre-merge-command] before any git operations.- These receive {target} placeholder for the target branch. Commands run sequentially- and any failure aborts the merge immediately. Skip with --no-verify.--3. Auto-commit uncommitted changes+2. Auto-commit uncommitted changesIf working tree has uncommitted changes, stages all changes (git add -A) and commitswith LLM-generated message.-4. Squash commits (default)+3. Squash commits (default)By default, counts commits since merge base with target branch. When multiplecommits exist, squashes them into one with LLM-generated message. Skip squashingwith --no-squash.-5. Rebase onto target+4. Rebase onto targetRebases current branch onto target branch. Detects conflicts and aborts if found.+ This fails fast before running expensive checks.++5. Run pre-merge commands+ Runs commands from project config's [pre-merge-command] after rebase completes.+ These receive {target} placeholder for the target branch. Commands run sequentially+ and any failure aborts the merge immediately. Skip with --no-hooks.6. Push to targetFast-forward pushes to target branch. Rejects non-fast-forward pushes (ensures@@ -262,7 +263,7 @@ Keep worktree after merging:wt merge --keepSkip pre-merge commands:- wt merge --no-verify")]+ wt merge --no-hooks")]Merge {/// Target branch to merge into (defaults to default branch)target: Option<String>,