Skip to content

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

fix: improve BranchAlreadyExists hint wording (#797)

Maximilian Roos483f806e8371
diff --git a/src/git/error.rs b/src/git/error.rs
index a65c2524b..d47ff7640 100644
--- a/src/git/error.rs
+++ b/src/git/error.rs
@@ -310,7 +310,7 @@ impl std::fmt::Display for GitError {
"{}\n{}",
error_message(cformat!("Branch <bold>{branch}</> already exists")),
hint_message(cformat!(
- "To switch to the existing branch, remove <bright-black>--create</> and run <bright-black>{switch_cmd}</>"
+ "To switch to the existing branch, run without <bright-black>--create</>: <bright-black>{switch_cmd}</>"
))
)
}
@@ -935,7 +935,7 @@ mod tests {
let downcast = err.downcast_ref::<GitError>().expect("Should downcast");
assert_snapshot!(downcast.to_string(), @"
✗ Branch main already exists
- ↳ To switch to the existing branch, remove --create and run wt switch main
+ ↳ To switch to the existing branch, run without --create: wt switch main
");
}
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__branch_already_exists.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__branch_already_exists.snap
index 7009724da..799d9172b 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__branch_already_exists.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__branch_already_exists.snap
@@ -3,4 +3,4 @@ source: tests/integration_tests/git_error_display.rs
expression: err.to_string()
---
✗ Branch feature already exists
-↳ To switch to the existing branch, remove --create and run wt switch feature
+↳ To switch to the existing branch, run without --create: wt switch feature
diff --git a/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap
index ce5747f2d..09367b92c 100644
--- a/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap
+++ b/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap
@@ -38,4 +38,4 @@ exit_code: 1
----- stderr -----
✗ Branch __WORKTRUNK_CD__/tmp already exists
-↳ To switch to the existing branch, remove --create and run wt switch __WORKTRUNK_CD__/tmp
+↳ To switch to the existing branch, run without --create: wt switch __WORKTRUNK_CD__/tmp
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__command_failure.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__command_failure.snap
index d97aaa91d..4b4ca7bde 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__command_failure.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__unix_tests__command_failure.snap
@@ -4,4 +4,4 @@ expression: "&output.combined"
---
✗ Branch existing already exists
-↳ To switch to the existing branch, remove --create and run wt switch existing
+↳ To switch to the existing branch, run without --create: wt switch existing
diff --git a/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap b/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
index 082a3bca0..de2f6de2f 100644
--- a/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
+++ b/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap
@@ -37,4 +37,4 @@ exit_code: 1
----- stderr -----
✗ Branch feature-y already exists
-↳ To switch to the existing branch, remove --create and run wt switch feature-y
+↳ To switch to the existing branch, run without --create: wt switch feature-y