Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Improve error messages with actionable commands and hints
Maximilian Roos930c5842acaf
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rsindex 0087245c0..1c99391bb 100644--- a/src/commands/worktree.rs+++ b/src/commands/worktree.rs@@ -595,6 +595,7 @@ pub fn handle_switch(.with_context(|| format!("Failed to move {path_display} to {backup_display}"))?;} else {return Err(GitError::WorktreePathExists {+ branch: resolved_branch.clone(),path: worktree_path,}.into());@@ -642,6 +643,7 @@ pub fn handle_switch(}){return Err(GitError::WorktreePathExists {+ branch: resolved_branch.clone(),path: std::path::PathBuf::from(path_str),}.into());diff --git a/src/git/error.rs b/src/git/error.rsindex 1a12d9c1a..5eb520641 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -9,9 +9,11 @@//! - **`WorktrunkError`** - A minimal enum for semantic errors that need//! special handling (exit codes, silent errors).+use std::borrow::Cow;use std::path::PathBuf;use color_print::{cformat, cwrite};+use shell_escape::escape;use super::HookType;use crate::path::format_path_for_display;@@ -72,6 +74,7 @@ pub enum GitError {occupant: Option<String>,},WorktreePathExists {+ branch: String,path: PathBuf,},WorktreeCreationFailed {@@ -146,7 +149,7 @@ impl std::fmt::Display for GitError {"{}\n\n{}",error_message(&message),hint_message(cformat!(- "Switch to a branch first with <bright-black>git switch <<branch>></>"+ "To switch to a branch, run <bright-black>git switch <<branch>></>")))}@@ -173,12 +176,13 @@ impl std::fmt::Display for GitError {}GitError::BranchAlreadyExists { branch } => {+ let switch_cmd = suggest_command("switch", &[branch], &[]);write!(f,"{}\n\n{}",error_message(cformat!("Branch <bold>{branch}</> already exists")),hint_message(cformat!(- "Remove <bright-black>--create</> flag to switch to the existing branch"+ "To switch to the existing branch, remove <bright-black>--create</>; run <bright-black>{switch_cmd}</>")))}@@ -236,11 +240,10 @@ impl std::fmt::Display for GitError {} else {cformat!("existing worktree at <bold>{path_display}</>, detached")};- // Hint is self-contained (includes both path and branch)- let hint = hint_message(cformat!(- "Switch the worktree at <bright-black>{path_display}</> to <bright-black>{branch}</>"- ));- let command = format!("cd {path_display} && git switch {branch}");+ // Hint leads into the command in the gutter block+ let hint = hint_message("To switch the worktree to this branch:");+ let path_escaped = escape(Cow::Borrowed(path_display.as_ref()));+ let command = format!("cd {path_escaped} && git switch {branch}");write!(f,"{}\n\n{}\n{}",@@ -252,8 +255,11 @@ impl std::fmt::Display for GitError {)}- GitError::WorktreePathExists { path } => {+ GitError::WorktreePathExists { branch, path } => {let path_display = format_path_for_display(path);+ let path_str = path.to_string_lossy();+ let path_escaped = escape(Cow::Borrowed(path_str.as_ref()));+ let switch_cmd = suggest_command("switch", &[branch], &["--clobber"]);write!(f,"{}\n\n{}",@@ -261,7 +267,7 @@ impl std::fmt::Display for GitError {"Directory already exists: <bold>{path_display}</>")),hint_message(cformat!(- "Use <bright-black>--clobber</> to remove, or <bright-black>rm -rf {path_display}</>"+ "To remove manually, run <bright-black>rm -rf {path_escaped}</>; to retry with backup, run <bright-black>{switch_cmd}</>")))}@@ -362,12 +368,13 @@ impl std::fmt::Display for GitError {}GitError::MergeCommitsFound => {+ let merge_cmd = suggest_command("merge", &[], &["--allow-merge-commits"]);write!(f,"{}\n\n{}",error_message("Found merge commits in push range"),hint_message(cformat!(- "To push non-linear history, add <bright-black>--allow-merge-commits</>"+ "To push non-linear history, run <bright-black>{merge_cmd}</>")))}@@ -388,10 +395,10 @@ impl std::fmt::Display for GitError {f,"\n\n{}\n{}",hint_message(cformat!(- "Resolve conflicts and run <bright-black>git rebase --continue</>"+ "To continue after resolving conflicts, run <bright-black>git rebase --continue</>")),hint_message(cformat!(- "Or abort with <bright-black>git rebase --abort</>"+ "To abort, run <bright-black>git rebase --abort</>")))}@@ -415,12 +422,13 @@ impl std::fmt::Display for GitError {}GitError::NotInteractive => {+ let approvals_cmd = suggest_command("hook", &["approvals", "add"], &[]);write!(f,"{}\n\n{}",error_message("Cannot prompt for approval in non-interactive environment"),hint_message(cformat!(- "In CI/CD, use <bright-black>--force</> to skip prompts. To pre-approve commands, use <bright-black>wt hook approvals add</>"+ "To skip prompts in CI/CD, add <bright-black>--force</>; to pre-approve commands, run <bright-black>{approvals_cmd}</>")))}@@ -616,12 +624,12 @@ impl std::fmt::Display for HookErrorWithHint {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {// Display the original error (always HookCommandFailed - validated by add_hook_skip_hint)write!(f, "{}", self.inner)?;- // Add the hint+ // Can't derive command from hook type (e.g., PreRemove is used by both `wt remove` and `wt merge`)write!(f,"\n\n{}",hint_message(cformat!(- "To skip {} commands, add <bright-black>--no-verify</>",+ "To skip {} hooks, re-run with <bright-black>--no-verify</>",self.hook_type)))@@ -656,7 +664,7 @@ mod tests {assert_snapshot!(err.to_string(), @r"β [31mNot on a branch (detached HEAD)[39m- π‘ [2mSwitch to a branch first with [90mgit switch <branch>[39m[22m+ π‘ [2mTo switch to a branch, run [90mgit switch <branch>[39m[22m");}@@ -685,7 +693,7 @@ mod tests {assert_snapshot!(downcast.to_string(), @r"β [31mBranch [1mmain[22m already exists[39m- π‘ [2mRemove [90m--create[39m flag to switch to the existing branch[22m+ π‘ [2mTo switch to the existing branch, remove [90m--create[39m; run [90mwt switch main[39m[22m");}@@ -706,12 +714,13 @@ mod tests {#[test]fn snapshot_worktree_error_with_path() {let err = GitError::WorktreePathExists {+ branch: "feature".to_string(),path: PathBuf::from("/some/path"),};assert_snapshot!(err.to_string(), @r"β [31mDirectory already exists: [1m/some/path[22m[39m- π‘ [2mUse [90m--clobber[39m to remove, or [90mrm -rf /some/path[39m[22m+ π‘ [2mTo remove manually, run [90mrm -rf /some/path[39m; to retry with backup, run [90mwt switch feature --clobber[39m[22m");}diff --git a/tests/integration_tests/git_error_display.rs b/tests/integration_tests/git_error_display.rsindex bd9522780..5087c942e 100644--- a/tests/integration_tests/git_error_display.rs+++ b/tests/integration_tests/git_error_display.rs@@ -60,6 +60,7 @@ fn display_worktree_path_occupied() {#[test]fn display_worktree_path_exists() {let err = GitError::WorktreePathExists {+ branch: "feature".to_string(),path: PathBuf::from("/tmp/repo.feature"),};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.snapindex f069453d3..3ae09d859 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@@ -1,7 +1,7 @@----source: tests/git_error_display.rs+source: tests/integration_tests/git_error_display.rsexpression: err.to_string()---β [31mBranch [1mfeature[22m already exists[39m-π‘ [2mRemove [90m--create[39m flag to switch to the existing branch[22m+π‘ [2mTo switch to the existing branch, remove [90m--create[39m; run [90mwt switch feature[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head.snapindex 8afaf2147..f0f5d123d 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head.snap@@ -1,7 +1,7 @@----source: tests/git_error_display.rs+source: tests/integration_tests/git_error_display.rsexpression: err.to_string()---β [31mCannot merge: not on a branch (detached HEAD)[39m-π‘ [2mSwitch to a branch first with [90mgit switch <branch>[39m[22m+π‘ [2mTo switch to a branch, run [90mgit switch <branch>[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head_no_action.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head_no_action.snapindex 70cf6083a..4461907c8 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head_no_action.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__detached_head_no_action.snap@@ -1,7 +1,7 @@----source: tests/git_error_display.rs+source: tests/integration_tests/git_error_display.rsexpression: err.to_string()---β [31mNot on a branch (detached HEAD)[39m-π‘ [2mSwitch to a branch first with [90mgit switch <branch>[39m[22m+π‘ [2mTo switch to a branch, run [90mgit switch <branch>[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__hook_command_failed_with_skip_hint.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__hook_command_failed_with_skip_hint.snapindex 2fe09f073..ea39d9b91 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__hook_command_failed_with_skip_hint.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__hook_command_failed_with_skip_hint.snap@@ -4,4 +4,4 @@ expression: err_with_hint.to_string()---β [31mpre-merge command failed: [1mtest[22m: exit code 1[39m-π‘ [2mTo skip pre-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__merge_commits_found.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__merge_commits_found.snapindex 881b05c29..60e883446 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__merge_commits_found.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__merge_commits_found.snap@@ -4,4 +4,4 @@ expression: err.to_string()---β [31mFound merge commits in push range[39m-π‘ [2mTo push non-linear history, add [90m--allow-merge-commits[39m[22m+π‘ [2mTo push non-linear history, run [90mwt merge --allow-merge-commits[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snapindex bb1b8ca98..086a258c4 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__not_interactive.snap@@ -1,7 +1,7 @@----source: tests/git_error_display.rs+source: tests/integration_tests/git_error_display.rsexpression: err.to_string()---β [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_exists.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_exists.snapindex 5a7d91f44..723fbcc1e 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_exists.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_exists.snap@@ -4,4 +4,4 @@ expression: err.to_string()---β [31mDirectory already exists: [1m/tmp/repo.feature[22m[39m-π‘ [2mUse [90m--clobber[39m to remove, or [90mrm -rf /tmp/repo.feature[39m[22m+π‘ [2mTo remove manually, run [90mrm -rf /tmp/repo.feature[39m; to retry with backup, run [90mwt switch feature --clobber[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snapindex ccd385f63..ccb07908e 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__git_error_display__worktree_path_occupied.snap@@ -4,5 +4,5 @@ expression: err.to_string()---β [31mCannot create worktree for [1mfeature-z[22m: existing worktree at [1m/tmp/repo.feature-z[22m on [1mother-branch[22m[39m-π‘ [2mSwitch the worktree at [90m/tmp/repo.feature-z[39m to [90mfeature-z[39m[22m+π‘ [2mTo switch the worktree to this branch:[22m[107m [0m [2m[0m[2m[34mcd[0m[2m /tmp/repo.feature-z [0m[2m[36m&&[0m[2m [0m[2m[34mgit[0m[2m switch feature-z[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__command_failure.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__command_failure.snapindex 50662d332..04f9be73a 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__command_failure.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__command_failure.snap@@ -4,4 +4,4 @@ expression: output.normalized()---β [31mBranch [1mexisting[22m already exists[39m-π‘ [2mRemove [90m--create[39m flag to switch to the existing branch[22m+π‘ [2mTo switch to the existing branch, remove [90m--create[39m; run [90mwt switch existing[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snapindex 250afddf6..65ff0330f 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap@@ -10,4 +10,4 @@ expression: output.normalized()β Test suite failed: 3 tests failingβ [31mpre-merge command failed: [1mtest[22m: exit status: 1[39m-π‘ [2mTo skip pre-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snapindex 250afddf6..65ff0330f 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap@@ -10,4 +10,4 @@ expression: output.normalized()β Test suite failed: 3 tests failingβ [31mpre-merge command failed: [1mtest[22m: exit status: 1[39m-π‘ [2mTo skip pre-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snapindex db9cee6a5..a84c61bd1 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_fails_in_non_tty.snap@@ -7,6 +7,7 @@ info:- "--create"- test-non-ttyenv:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -14,10 +15,16 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: falseexit_code: 1@@ -30,4 +37,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snapindex c0098a114..1627b4f42 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_mixed_approved_unapproved.snap@@ -14,4 +14,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snapindex 914562faf..894043ba1 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap@@ -18,4 +18,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mcd[0m[2m {{ worktree }} [0m[2m[36m&&[0m[2m [0m[2m[34mpwd[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snapindex 7bdd45031..8541cd0d5 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_named_commands.snap@@ -16,4 +16,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running tests...'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snapindex cca23b423..4e971f749 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_single_command.snap@@ -12,4 +12,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Worktree path: {{ worktree }}'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snapindex c0098a114..1627b4f42 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__decline_approval_skips_only_unapproved.snap@@ -14,4 +14,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Third command'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snapindex 17b1d3bbf..876e4f549 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__force_does_not_save_approvals_second_run.snap@@ -12,4 +12,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test command'[0m[2m [0m[2m[36m>[0m[2m output.txtβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snapindex d2c963836..ab97ded6e 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_post_merge_requires_approval.snap@@ -12,4 +12,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Post-merge cleanup for {{ branch }}'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snapindex b18572282..0c3177551 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__run_hook_pre_merge_requires_approval.snap@@ -12,4 +12,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Running pre-merge checks on {{ branch }}'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snapindex a9e9816a3..92f1c4655 100644--- a/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap+++ b/tests/snapshots/integration__integration_tests__approvals__add_approvals_all_none_approved.snap@@ -8,6 +8,7 @@ info:- add- "--all"env:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -15,10 +16,16 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: falseexit_code: 1@@ -31,4 +38,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'test'[0m[2mβ [31mCannot prompt for approval in non-interactive environment[39m-π‘ [2mIn CI/CD, use [90m--force[39m to skip prompts. To pre-approve commands, use [90mwt hook approvals add[39m[22m+π‘ [2mTo skip prompts in CI/CD, add [90m--force[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap b/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snapindex 7008267ba..a492d52db 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_error_detached_head.snap@@ -6,6 +6,7 @@ info:- merge- mainenv:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -13,10 +14,16 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: falseexit_code: 1@@ -25,4 +32,4 @@ exit_code: 1----- stderr -----β [31mCannot merge: not on a branch (detached HEAD)[39m-π‘ [2mSwitch to a branch first with [90mgit switch <branch>[39m[22m+π‘ [2mTo switch to a branch, run [90mgit switch <branch>[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snapindex ab1a0c83d..b8a2e4455 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_post_merge_command_failure.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -41,4 +42,4 @@ exit_code: 1[0mπ‘ [33mCommand failed: exit status: 1[39mβ [31mpost-merge command failed: exit status: 1[39m-π‘ [2mTo skip post-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip post-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snapindex f90545eea..721ed8e8d 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_commit_command_failure.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -36,4 +37,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-commit command failed: exit status: 1[39m-π‘ [2mTo skip pre-commit commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-commit hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snapindex c3b29d00b..a9bc26161 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_merge_command_failure.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -34,4 +35,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-merge command failed: exit status: 1[39m-π‘ [2mTo skip pre-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snapindex a557aa3e5..d8b4e3a8a 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_pre_squash_command_failure.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -34,4 +35,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-commit command failed: exit status: 1[39m-π‘ [2mTo skip pre-commit commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-commit hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snapindex 7b53ff818..29f47a913 100644--- a/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap+++ b/tests/snapshots/integration__integration_tests__push__push_error_with_merge_commits.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -32,4 +33,4 @@ exit_code: 1----- stderr -----β [31mFound merge commits in push range[39m-π‘ [2mTo push non-linear history, add [90m--allow-merge-commits[39m[22m+π‘ [2mTo push non-linear history, run [90mwt merge --allow-merge-commits[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snapindex aef3f2903..42ab57819 100644--- a/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap+++ b/tests/snapshots/integration__integration_tests__remove__pre_remove_hook_failure_aborts.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -35,4 +36,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-remove command failed: exit status: 1[39m-π‘ [2mTo skip pre-remove commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-remove hooks, re-run with [90m--no-verify[39m[22mdiff --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.snapindex 9b7ff87f4..1e44c94ab 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@@ -8,6 +8,7 @@ info:- "--create"- __WORKTRUNK_CD__/tmpenv:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -15,10 +16,16 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: falseexit_code: 1@@ -27,4 +34,4 @@ exit_code: 1----- stderr -----[0mβ [31mBranch [1m__WORKTRUNK_CD__/tmp[22m already exists[39m-π‘ [2mRemove [90m--create[39m flag to switch to the existing branch[22m+π‘ [2mTo switch to the existing branch, remove [90m--create[39m; run [90mwt switch __WORKTRUNK_CD__/tmp[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snap b/tests/snapshots/integration__integration_tests__switch__switch_create_existing_error.snapindex c1db5dcaf..41bec5ee6 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@@ -7,6 +7,7 @@ info:- "--create"- feature-yenv:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -14,12 +15,16 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: falseexit_code: 1@@ -28,4 +33,4 @@ exit_code: 1----- stderr -----β [31mBranch [1mfeature-y[22m already exists[39m-π‘ [2mRemove [90m--create[39m flag to switch to the existing branch[22m+π‘ [2mTo switch to the existing branch, remove [90m--create[39m; run [90mwt switch feature-y[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snapindex 59f569694..3cf71ce9c 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_main_worktree_on_different_branch.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -32,5 +33,5 @@ exit_code: 1----- stderr -----[0mβ [31mCannot create worktree for [1mmain[22m: existing worktree at [1m[REPO][22m on [1mfeature[22m[39m-π‘ [2mSwitch the worktree at [90m[REPO][39m to [90mmain[39m[22m+π‘ [2mTo switch the worktree to this branch:[22m[107m [0m [2m[0m[2m[34mcd[0m[2m [REPO] [0m[2m[36m&&[0m[2m [0m[2m[34mgit[0m[2m switch maindiff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snapindex 751e79889..4f0135481 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -32,4 +33,4 @@ exit_code: 1----- stderr -----β [31mDirectory already exists: [1m[REPO].occupied-branch[22m[39m-π‘ [2mUse [90m--clobber[39m to remove, or [90mrm -rf [REPO].occupied-branch[39m[22m+π‘ [2mTo remove manually, run [90mrm -rf [REPO].occupied-branch[39m; to retry with backup, run [90mwt switch occupied-branch --clobber[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snapindex 084993507..0916a28d5 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_detached.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -32,5 +33,5 @@ exit_code: 1----- stderr -----[0mβ [31mCannot create worktree for [1mfeature[22m: existing worktree at [1m[REPO].feature[22m, detached[39m-π‘ [2mSwitch the worktree at [90m[REPO].feature[39m to [90mfeature[39m[22m+π‘ [2mTo switch the worktree to this branch:[22m[107m [0m [2m[0m[2m[34mcd[0m[2m [REPO].feature [0m[2m[36m&&[0m[2m [0m[2m[34mgit[0m[2m switch featurediff --git a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snapindex e6bafbcce..75132c545 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_error_path_occupied_different_branch.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -32,5 +33,5 @@ exit_code: 1----- stderr -----[0mβ [31mCannot create worktree for [1mfeature[22m: existing worktree at [1m[REPO].feature[22m on [1mbugfix[22m[39m-π‘ [2mSwitch the worktree at [90m[REPO].feature[39m to [90mfeature[39m[22m+π‘ [2mTo switch the worktree to this branch:[22m[107m [0m [2m[0m[2m[34mcd[0m[2m [REPO].feature [0m[2m[36m&&[0m[2m [0m[2m[34mgit[0m[2m switch featurediff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snapindex b1b50f581..53fae67bd 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_commit_failure.snap@@ -21,6 +21,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -37,4 +38,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-commit command failed: [1mlint[22m: exit status: 1[39m-π‘ [2mTo skip pre-commit commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-commit hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snapindex 04487b799..39d4e1f49 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_merge_failure.snap@@ -21,6 +21,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -35,4 +36,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-merge command failed: [1mcheck[22m: exit status: 1[39m-π‘ [2mTo skip pre-merge commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-merge hooks, re-run with [90m--no-verify[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snapindex 22023b40b..a4bef58d0 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_failure.snap@@ -20,6 +20,7 @@ info:LANG: CLC_ALL: CPATH: "[PATH]"+ RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"@@ -34,4 +35,4 @@ exit_code: 1[107m [0m [2m[0m[2m[34mexit[0m[2m 1[0mβ [31mpre-remove command failed: [1mblock[22m: exit status: 1[39m-π‘ [2mTo skip pre-remove commands, add [90m--no-verify[39m[22m+π‘ [2mTo skip pre-remove hooks, re-run with [90m--no-verify[39m[22m