Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Refactor merge main branch logic for clarity
Maximilian Roos2677c406ab83
diff --git a/src/commands/merge.rs b/src/commands/merge.rsindex c84e574ac..522c8cb56 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -17,8 +17,8 @@ use super::worktree::{MergeOperations, RemoveResult, handle_push};enum PreserveReason {/// User explicitly passed --no-removeNoRemoveFlag,- /// Running from the main worktree (can't remove main)- OnMainBranch,+ /// Running from the main worktree (can't remove main worktree)+ IsMainWorktree,/// Current branch is the same as the target branchAlreadyOnTarget,}@@ -224,9 +224,9 @@ pub fn handle_merge(crate::output::handle_remove_output(&remove_result, Some(¤t_branch), true)?;} else {// Print comprehensive summary (worktree preserved)- // Priority: main branch > on target > --no-remove flag+ // Priority: main worktree > on target > --no-remove flaglet reason = if in_main {- PreserveReason::OnMainBranch+ PreserveReason::IsMainWorktree} else if on_target {PreserveReason::AlreadyOnTarget} else {@@ -258,7 +258,7 @@ pub fn handle_merge(/// Handle output for merge summary using global output contextfn handle_merge_summary_output(reason: PreserveReason) -> anyhow::Result<()> {let message = match reason {- PreserveReason::OnMainBranch => "Worktree preserved (on main branch)",+ PreserveReason::IsMainWorktree => "Worktree preserved (main worktree)",PreserveReason::AlreadyOnTarget => "Worktree preserved (already on target)",PreserveReason::NoRemoveFlag => "Worktree preserved (--no-remove)",};diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snapindex f7fcfd543..03f577b29 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge.snap@@ -3,4 +3,4 @@ source: tests/integration_tests/shell_wrapper.rsexpression: output.normalized()---⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)-⚪ Worktree preserved (on main branch)+⚪ Worktree preserved (main worktree)diff --git a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snapindex 08201a4b1..cfbe0d890 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_already_on_target.snap@@ -24,4 +24,4 @@ exit_code: 0----- stderr -----⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)-⚪ Worktree preserved (on main branch)+⚪ Worktree preserved (main worktree)diff --git a/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap b/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snapindex 08201a4b1..cfbe0d890 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_default_branch_missing_worktree.snap@@ -24,4 +24,4 @@ exit_code: 0----- stderr -----⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)-⚪ Worktree preserved (on main branch)+⚪ Worktree preserved (main worktree)diff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snapindex bb35e1137..c073662ca 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_runs_from_main_branch.snap@@ -25,7 +25,7 @@ exit_code: 0----- stderr -----⚪ Already up to date with [1mmain[22m (no new commits, no rebase needed)-⚪ Worktree preserved (on main branch)+⚪ Worktree preserved (main worktree)🔄 [36mRunning post-merge:[39m[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'post-merge ran from main'[0m[2m [0m[2m[36m>[0m[2m post-merge-ran.txt[0m[0m