Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Simplify handle_remove_output signature

Maximilian Roosfea7f784373e
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index 072ca1827..351790b27 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -249,7 +249,7 @@ pub fn handle_merge(opts: MergeOptions<'_>) -> anyhow::Result<()> {
};
// Run hooks during merge removal (pass through verify flag)
// Approval was handled at the gate (MergeCommandCollector)
- crate::output::handle_remove_output(&remove_result, Some(&current_branch), true, verify)?;
+ crate::output::handle_remove_output(&remove_result, true, verify)?;
} else {
// Print comprehensive summary (worktree preserved)
// Priority: main worktree > on target > --no-remove flag
diff --git a/src/main.rs b/src/main.rs
index 8a9ff6f20..f9f85b286 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1384,7 +1384,7 @@ fn main() {
.context("Failed to remove worktree")?;
// Approval was handled at the gate
// Post-switch hooks are spawned internally by handle_remove_output
- handle_remove_output(&result, None, background, verify)
+ handle_remove_output(&result, background, verify)
} else {
use worktrunk::git::ResolvedWorktree;
// When removing multiple worktrees, we need to handle the current worktree last
@@ -1433,12 +1433,7 @@ fn main() {
background,
) {
Ok(result) => {
- handle_remove_output(
- &result,
- Some(branch_name),
- background,
- verify,
- )?;
+ handle_remove_output(&result, background, verify)?;
}
Err(e) => {
output::print(e.to_string())?;
@@ -1449,7 +1444,7 @@ fn main() {
// Non-current worktree is detached - remove by path (no branch to delete)
match handle_remove_by_path(path, None, background) {
Ok(result) => {
- handle_remove_output(&result, None, background, verify)?;
+ handle_remove_output(&result, background, verify)?;
}
Err(e) => {
output::print(e.to_string())?;
@@ -1463,7 +1458,7 @@ fn main() {
for branch in &branch_only {
match handle_remove(branch, !delete_branch, force_delete, background) {
Ok(result) => {
- handle_remove_output(&result, Some(branch), background, verify)?;
+ handle_remove_output(&result, background, verify)?;
}
Err(e) => {
output::print(e.to_string())?;
@@ -1474,15 +1469,10 @@ fn main() {
// Remove current worktree last (if it was in the list)
// Post-switch hooks are spawned internally by handle_remove_output
- if let Some((_path, branch)) = current {
+ if let Some((_path, _branch)) = current {
match handle_remove_current(!delete_branch, force_delete, background) {
Ok(result) => {
- handle_remove_output(
- &result,
- branch.as_deref(),
- background,
- verify,
- )?;
+ handle_remove_output(&result, background, verify)?;
}
Err(e) => {
output::print(e.to_string())?;
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 105cb7471..81175dbad 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -447,7 +447,6 @@ fn build_remove_command(worktree_path: &std::path::Path, branch_to_delete: Optio
/// Approval is handled at the gate (command entry point), not here.
pub fn handle_remove_output(
result: &RemoveResult,
- branch: Option<&str>,
background: bool,
verify: bool,
) -> anyhow::Result<()> {
@@ -468,7 +467,6 @@ pub fn handle_remove_output(
*deletion_mode,
target_branch.as_deref(),
*integration_reason,
- branch,
background,
verify,
),
@@ -562,7 +560,6 @@ fn handle_removed_worktree_output(
deletion_mode: BranchDeletionMode,
target_branch: Option<&str>,
pre_computed_integration: Option<IntegrationReason>,
- branch: Option<&str>,
background: bool,
verify: bool,
) -> anyhow::Result<()> {
@@ -766,10 +763,6 @@ fn handle_removed_worktree_output(
outcome,
BranchDeletionOutcome::ForceDeleted | BranchDeletionOutcome::Integrated(_)
);
- // Use branch if provided, otherwise fall back to branch_name (which is always
- // Some here since we returned early for detached HEAD case on line 565)
- let branch_display = branch.unwrap_or(branch_name);
-
// Message structure parallel to background mode:
// - Branch deleted (integrated/force): "worktree & branch (reason)"
// - Branch kept (any reason): "worktree" + hint (if relevant)
@@ -778,11 +771,11 @@ fn handle_removed_worktree_output(
let flag_text = &flag_note.text;
let flag_after = flag_note.after_green();
cformat!(
- "<green>✓ Removed <bold>{branch_display}</> worktree & branch{flag_text}</>{flag_after}"
+ "<green>✓ Removed <bold>{branch_name}</> worktree & branch{flag_text}</>{flag_after}"
)
} else {
// Branch kept: hint will explain why (integrated+flag, unmerged, or unmerged+flag)
- cformat!("<green>✓ Removed <bold>{branch_display}</> worktree</>")
+ cformat!("<green>✓ Removed <bold>{branch_name}</> worktree</>")
};
super::print(FormattedMessage::new(msg))?;