Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(remove): stop suggesting -D when refusing to remove the default branch (#4535)
Maximilian Roosaf3c278fa9b9
diff --git a/src/git/error.rs b/src/git/error.rsindex 76f320437..54a65f787 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -1429,22 +1429,11 @@ impl GitError {Ok(())}- GitError::CannotRemoveMainWorktree => {+ GitError::CannotRemoveMainWorktree | GitError::CannotRemoveDefaultBranch { .. } => {let title = self.title();write!(f, "{}", error_message(&title))}- GitError::CannotRemoveDefaultBranch { branch } => {- let title = self.title();- let cmd = suggest_command("remove", &[branch], &["-D"]);- write!(- f,- "{}\n{}",- error_message(&title),- hint_message(cformat!("To force-delete, run <underline>{cmd}</>"))- )- }-GitError::WorktreeLocked { path, .. } => {let title = self.title();let path_display = format_path_for_display(path);diff --git a/tests/integration_tests/bare_repository.rs b/tests/integration_tests/bare_repository.rsindex e26579721..1d49cf1d8 100644--- a/tests/integration_tests/bare_repository.rs+++ b/tests/integration_tests/bare_repository.rs@@ -791,7 +791,6 @@ fn test_bare_repo_remove_from_bare_directory_targets_head_branch() {assert!(main_worktree.exists());insta::assert_snapshot!(String::from_utf8_lossy(&no_arg.stderr), @"✗ Cannot remove the default branch main- ↳ To force-delete, run wt remove -D main");}diff --git a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_branch_only_refused.snap b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_branch_only_refused.snapindex 2aa9d2459..84d243d70 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_branch_only_refused.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_branch_only_refused.snap@@ -51,4 +51,3 @@ exit_code: 1----- stderr -----✗ Cannot remove the default branch main-↳ To force-delete, run wt remove -D maindiff --git a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_refused.snap b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_refused.snapindex 9a8eb4032..47f351a89 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_refused.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_refused.snap@@ -52,4 +52,3 @@ exit_code: 1----- stderr -----✗ Cannot remove the default branch main-↳ To force-delete, run wt remove -D maindiff --git a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_with_detached_main_worktree.snap b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_with_detached_main_worktree.snapindex 2d6a87c45..dc14464d5 100644--- a/tests/snapshots/integration__integration_tests__remove__remove_default_branch_with_detached_main_worktree.snap+++ b/tests/snapshots/integration__integration_tests__remove__remove_default_branch_with_detached_main_worktree.snap@@ -60,4 +60,3 @@ exit_code: 1----- stderr -----[31m✗[39m [31mCannot remove the default branch [1mmain[22m[39m-[2m↳[22m [2mTo force-delete, run [4mwt remove -D main[24m[22m