Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: clean up prune output — silent skip, no noise (#1236)
Maximilian Roos921a5afadfaf
diff --git a/src/commands/merge.rs b/src/commands/merge.rsindex 417f283fa..0fdd90552 100644--- a/src/commands/merge.rs+++ b/src/commands/merge.rs@@ -269,7 +269,7 @@ pub fn handle_merge(opts: MergeOptions<'_>) -> anyhow::Result<()> {};// Run hooks during merge removal (pass through verify flag)// Approval was handled at the gate (collect_merge_commands)- crate::output::handle_remove_output(&remove_result, true, verify)?;+ crate::output::handle_remove_output(&remove_result, true, verify, false)?;} else {// Worktree preserved - show reason (priority: main worktree > on target > --no-remove flag)let message = if in_main {diff --git a/src/commands/step_commands.rs b/src/commands/step_commands.rsindex d39598df1..1a209aaf9 100644--- a/src/commands/step_commands.rs+++ b/src/commands/step_commands.rs@@ -1419,15 +1419,13 @@ pub fn step_prune(dry_run: bool, yes: bool, min_age: &str, foreground: bool) ->config,) {Ok(plan) => plan,- Err(e) => {- eprintln!(- "{}",- warning_message(format!("Skipping {}: {e:#}", candidate.label))- );+ Err(_) => {+ // prepare_worktree_removal is the gate: if the worktree can't+ // be removed (dirty, locked, etc.), it's simply not selected.return Ok(false);}};- handle_remove_output(&plan, !foreground, run_hooks)?;+ handle_remove_output(&plan, !foreground, run_hooks, true)?;Ok(true)}diff --git a/src/main.rs b/src/main.rsindex 1d63ee259..b01f591d7 100644--- a/src/main.rs+++ b/src/main.rs@@ -842,7 +842,7 @@ fn main() {// "Approve at the Gate": approval happens AFTER validation passeslet run_hooks = verify && approve_remove(yes)?;- handle_remove_output(&result, background, run_hooks)+ handle_remove_output(&result, background, run_hooks, false)} else {// Multi-worktree removal: validate ALL first, then approve, then execute// This supports partial success - some may fail validation while others succeed.@@ -961,17 +961,17 @@ fn main() {// Phase 3: Execute all validated plans// Remove other worktrees firstfor result in plans_others {- handle_remove_output(&result, background, run_hooks)?;+ handle_remove_output(&result, background, run_hooks, false)?;}// Handle branch-only casesfor result in plans_branch_only {- handle_remove_output(&result, background, run_hooks)?;+ handle_remove_output(&result, background, run_hooks, false)?;}// Remove current worktree last (if it was in the list)if let Some(result) = plan_current {- handle_remove_output(&result, background, run_hooks)?;+ handle_remove_output(&result, background, run_hooks, false)?;}// Exit with failure if any validation errors occurreddiff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 6ea9d25fc..be9011160 100644--- a/src/output/handlers.rs+++ b/src/output/handlers.rs@@ -626,10 +626,13 @@ pub fn execute_user_command(command: &str, display_path: Option<&Path>) -> anyho/// Handle output for a remove operation////// Approval is handled at the gate (command entry point), not here.+/// When `quiet` is true (prune context), suppresses informational messages+/// like "No worktree found for branch X" that are noise in batch operations.pub fn handle_remove_output(result: &RemoveResult,background: bool,verify: bool,+ quiet: bool,) -> anyhow::Result<()> {match result {RemoveResult::RemovedWorktree {@@ -661,15 +664,19 @@ pub fn handle_remove_output(branch_name,deletion_mode,pruned,- } => handle_branch_only_output(branch_name, *deletion_mode, *pruned),+ } => handle_branch_only_output(branch_name, *deletion_mode, *pruned, quiet),}}/// Handle output for BranchOnly removal (branch exists but no worktree)+///+/// When `quiet` is true, suppresses the "No worktree found for branch X"+/// info line for non-pruned cases (noise in prune/batch context).fn handle_branch_only_output(branch_name: &str,deletion_mode: BranchDeletionMode,pruned: bool,+ quiet: bool,) -> anyhow::Result<()> {let branch_info = if pruned {cformat!("Worktree directory missing for <bold>{branch_name}</>; pruned")@@ -731,7 +738,9 @@ fn handle_branch_only_output()));} else {- eprintln!("{}", info_message(&branch_info));+ if !quiet {+ eprintln!("{}", info_message(&branch_info));+ }eprintln!("{}",FormattedMessage::new(cformat!(diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branches.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branches.snapindex 93df5af9f..a5d59bdd9 100644--- a/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branches.snap+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_orphan_branches.snap@@ -42,8 +42,6 @@ exit_code: 0----- stdout ---------- stderr ------[2m○[22m No worktree found for branch [1morphan-a[22m[32m✓ Removed branch [1morphan-a[22m (same commit as [1mmain[22m,[39m [2m_[22m[32m)[39m-[2m○[22m No worktree found for branch [1morphan-b[22m[32m✓ Removed branch [1morphan-b[22m (same commit as [1mmain[22m,[39m [2m_[22m[32m)[39m[32m✓[39m [32mPruned 2 branches[39mdiff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_removes_integrated_detached.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_removes_integrated_detached.snapindex 0248952e8..720cd1e50 100644--- a/tests/snapshots/integration__integration_tests__step_prune__prune_removes_integrated_detached.snap+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_removes_integrated_detached.snap@@ -44,6 +44,5 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRemoving worktree @ [1m_REPO_.detached-integrated[22m in background (detached HEAD, no branch to delete)[39m-[2m○[22m No worktree found for branch [1mdetached-integrated[22m[32m✓ Removed branch [1mdetached-integrated[22m (same commit as [1mmain[22m,[39m [2m_[22m[32m)[39m[32m✓[39m [32mPruned 1 branch, 1 detached worktree[39mdiff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_skips_dirty.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_skips_dirty.snapindex 28356057b..4814d4d2a 100644--- a/tests/snapshots/integration__integration_tests__step_prune__prune_skips_dirty.snap+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_skips_dirty.snap@@ -44,6 +44,4 @@ exit_code: 0----- stderr -----[36m◎ Removing [1mclean-merged[22m worktree & branch in background (same commit as [1mmain[22m,[39m [2m_[22m[36m)[39m-[33m▲[39m [33mSkipping dirty-merged: [31m✗[39m [31mCannot remove worktree: [1mdirty-merged[22m has uncommitted changes[39m-[2m↳[22m [2mCommit or stash changes first, or to lose uncommitted changes, run [90mwt remove --force dirty-merged[39m[22m[39m[32m✓[39m [32mPruned 1 worktree (with branch)[39m