Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
style(output): bold paths in warning messages (#2677)
Maximilian Roos5144b1fbdc25
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rsindex 4834dd11f..3cebdab89 100644--- a/src/commands/config/show.rs+++ b/src/commands/config/show.rs@@ -782,7 +782,7 @@ fn render_fish_completion_status(out: &mut String, cmd: &str) -> anyhow::Result<)?;} else {let warning = warning_message(cformat!(- "<bold>{shell}</>: Completions not configured @ {completion_display}"+ "<bold>{shell}</>: Completions not configured @ <bold>{completion_display}</>"));let hint = hint_message(cformat!("To configure completions, run <underline>{cmd} config shell install {shell}</>"@@ -901,7 +901,7 @@ fn render_would_add_or_create(// so the generic "To configure" summary stays silent.if shell.is_wrapper_based() && matches!(result.action, ConfigAction::WouldAdd) {let warning = warning_message(cformat!(- "<bold>{shell}</>: Outdated shell extension @ {path}"+ "<bold>{shell}</>: Outdated shell extension @ <bold>{path}</>"));let hint = hint_message(cformat!("To update, run <underline>{cmd} config shell install {shell}</>"diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex 374817c31..7d41bef78 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -165,8 +165,8 @@ fn cleanup_legacy_fish_conf_d(configured: &[ConfigureResult], cmd: &str) -> Vec<// Warn but don't fail - the new integration will still workeprintln!("{}",- warning_message(format!(- "Failed to remove deprecated {}: {e}",+ warning_message(color_print::cformat!(+ "Failed to remove deprecated <bold>{}</>: {e}",format_path_for_display(&legacy_path))));diff --git a/src/config/user/mod.rs b/src/config/user/mod.rsindex 06a0234d4..ffe7bdb83 100644--- a/src/config/user/mod.rs+++ b/src/config/user/mod.rs@@ -437,8 +437,8 @@ impl UserConfig {{crate::styling::eprintln!("{}",- crate::styling::warning_message(format!(- "Config file not found: {}",+ crate::styling::warning_message(color_print::cformat!(+ "Config file not found: <bold>{}</>",crate::path::format_path_for_display(config_path))));diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 3bfc15350..183bbe54d 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -896,14 +896,7 @@ fn add_project_id_filters(settings: &mut insta::Settings) {/// This extracts the common settings configuration while allowing the/// `assert_cmd_snapshot!` macro to remain in test files for correct module path capture.pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {- setup_snapshot_settings_impl(repo.root_path(), None)-}--/// Internal implementation that optionally includes temp_home filter.-/// The temp_home filter MUST be added before PROJECT_ID filters to take precedence.-fn setup_snapshot_settings_impl(root: &Path, temp_home: Option<&Path>) -> insta::Settings {- let worktrees = HashMap::new(); // Caller doesn't need worktree filters- setup_snapshot_settings_for_paths_with_home(root, &worktrees, temp_home)+ setup_snapshot_settings_for_paths_with_home(repo.root_path(), &HashMap::new(), None)}/// Full snapshot settings - path filters AND ANSI cleanup.@@ -1097,11 +1090,14 @@ fn setup_snapshot_settings_for_paths_with_home(/// This extends `setup_snapshot_settings` by adding a filter for the temporary home directory./// Use this for tests that need both a TestRepo and a temporary home (for user config testing).///-/// IMPORTANT: The temp_home filter is passed to setup_snapshot_settings_impl so it gets added-/// BEFORE the generic [PROJECT_ID] filters. Otherwise, paths like /tmp/.tmpXXX/.config/worktrunk/config.toml-/// would match [PROJECT_ID] first.+/// IMPORTANT: The temp_home filter is added BEFORE the generic [PROJECT_ID] filters.+/// Otherwise, paths like /tmp/.tmpXXX/.config/worktrunk/config.toml would match [PROJECT_ID] first.pub fn setup_snapshot_settings_with_home(repo: &TestRepo, temp_home: &TempDir) -> insta::Settings {- setup_snapshot_settings_impl(repo.root_path(), Some(temp_home.path()))+ setup_snapshot_settings_for_paths_with_home(+ repo.root_path(),+ &HashMap::new(),+ Some(temp_home.path()),+ )}/// Create configured insta Settings for snapshot tests with only a temporary home directory@@ -1119,7 +1115,7 @@ pub fn setup_home_snapshot_settings(temp_home: &TempDir) -> insta::Settings {"[TEMP_HOME]",);settings.add_filter(r"\\", "/");- // Filter out PowerShell lines (see main filter in setup_snapshot_settings_impl for details)+ // Filter out PowerShell lines (see main filter in setup_snapshot_settings_for_paths_with_home for details)settings.add_filter(r"(?m)^.*[Pp]owershell(?:\x1b\[[0-9;]*m)*:.*\n", "");settings.add_filter(r"(?m)^.*No .*powershell.* shell extension.*\n", "");settings.add_filter(r"(?m)^.*shell init powershell.*\n", "");diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex 244b63162..21cd8e24c 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -466,6 +466,61 @@ fn test_uninstall_shell_fish_legacy_conf_d_cleanup(repo: TestRepo, temp_home: Te);}+/// Test that the legacy cleanup warns (but does not fail) when removal errors.+///+/// Makes the legacy conf.d directory read-only so `fs::remove_file` returns+/// EACCES. The install still succeeds via the new `functions/` location and+/// surfaces a warning naming the legacy file.+#[rstest]+#[cfg(unix)]+fn test_configure_shell_fish_legacy_remove_failure_warns(repo: TestRepo, temp_home: TempDir) {+ use std::fs::Permissions;+ use std::os::unix::fs::PermissionsExt;++ let conf_d = temp_home.path().join(".config/fish/conf.d");+ fs::create_dir_all(&conf_d).unwrap();+ let legacy_file = conf_d.join("wt.fish");+ fs::write(&legacy_file, "wt config shell init fish | source").unwrap();++ // Read-only parent dir → remove of contained file fails with EACCES.+ fs::set_permissions(&conf_d, Permissions::from_mode(0o555)).unwrap();++ // Skip when running as root — permissions don't restrict.+ let probe = conf_d.join("__probe");+ if fs::write(&probe, "").is_ok() {+ let _ = fs::remove_file(&probe);+ fs::set_permissions(&conf_d, Permissions::from_mode(0o755)).unwrap();+ eprintln!("Skipping - running with elevated privileges");+ return;+ }++ let mut cmd = wt_command();+ repo.configure_wt_cmd(&mut cmd);+ set_temp_home_env(&mut cmd, temp_home.path());+ cmd.env("SHELL", "/bin/fish");+ cmd.arg("config")+ .arg("shell")+ .arg("install")+ .arg("fish")+ .arg("--yes")+ .current_dir(repo.root_path());++ let output = cmd.output().unwrap();++ // Restore permissions so TempDir cleanup succeeds even if assertions fail.+ fs::set_permissions(&conf_d, Permissions::from_mode(0o755)).unwrap();++ let stderr = String::from_utf8_lossy(&output.stderr);+ assert!(+ output.status.success(),+ "Install should succeed despite legacy cleanup failure, got: {stderr}"+ );+ assert!(+ stderr.contains("Failed to remove deprecated") && stderr.contains("conf.d/wt.fish"),+ "Expected legacy-cleanup warning naming the path; got: {stderr}"+ );+}+/// Test that --dry-run does NOT delete legacy fish conf.d file////// Regression test: Previously, --dry-run could delete the legacy file becausediff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_fish_outdated_wrapper.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_fish_outdated_wrapper.snapindex 9a38d28bf..305a3fc95 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_fish_outdated_wrapper.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_fish_outdated_wrapper.snap@@ -61,7 +61,7 @@ exit_code: 0[33m▲[39m [33mShell integration not active[39m[107m [0m Invoked as: [1m[PROJECT_ROOT]/target/[BUILD_MODE]/wt[22m-[33m▲[39m [33m[1mfish[22m: Outdated shell extension @ ~/.config/fish/functions/wt.fish[39m+[33m▲[39m [33m[1mfish[22m: Outdated shell extension @ [1m~/.config/fish/functions/wt.fish[22m[39m[2m↳[22m [2mTo update, run [4mwt config shell install fish[24m[22m[36mOTHER[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_fish_without_completions.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_fish_without_completions.snapindex debdd9a23..8f4860a9a 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_fish_without_completions.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_fish_without_completions.snap@@ -63,7 +63,7 @@ exit_code: 0[2m○[22m [1mfish[22m: Already configured shell extension @ ~/.config/fish/functions/wt.fish:7[107m [0m [2m[0m[2m[34mcommand[0m[2m wt config shell init fish [0m[2m[36m|[0m[2m [0m[2m[34msource[0m[2m-[33m▲[39m [33m[1mfish[22m: Completions not configured @ ~/.config/fish/completions/wt.fish[39m+[33m▲[39m [33m[1mfish[22m: Completions not configured @ [1m~/.config/fish/completions/wt.fish[22m[39m[2m↳[22m [2mTo configure completions, run [4mwt config shell install fish[24m[22m[36mOTHER[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_nushell_outdated_wrapper.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_nushell_outdated_wrapper.snapindex ffeb69b5e..6524ca3d3 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_nushell_outdated_wrapper.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_nushell_outdated_wrapper.snap@@ -61,7 +61,7 @@ exit_code: 0[33m▲[39m [33mShell integration not active[39m[107m [0m Invoked as: [1m[PROJECT_ROOT]/target/[BUILD_MODE]/wt[22m-[33m▲[39m [33m[1mnu[22m: Outdated shell extension @ ~/.config/nushell/vendor/autoload/wt.nu[39m+[33m▲[39m [33m[1mnu[22m: Outdated shell extension @ [1m~/.config/nushell/vendor/autoload/wt.nu[22m[39m[2m↳[22m [2mTo update, run [4mwt config shell install nu[24m[22m[36mOTHER[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_not_suppressed_by_wrapper.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_not_suppressed_by_wrapper.snapindex 77a5e89cf..f7f09e838 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_not_suppressed_by_wrapper.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_not_suppressed_by_wrapper.snap@@ -63,7 +63,7 @@ exit_code: 0[107m [0m Invoked as: [1m[PROJECT_ROOT]/target/[BUILD_MODE]/wt[22m[2m○[22m [1mbash[22m: Not configured shell extension & completions-[33m▲[39m [33m[1mfish[22m: Outdated shell extension @ ~/.config/fish/functions/wt.fish[39m+[33m▲[39m [33m[1mfish[22m: Outdated shell extension @ [1m~/.config/fish/functions/wt.fish[22m[39m[2m↳[22m [2mTo update, run [4mwt config shell install fish[24m[22m[2m↳[22m [2mTo configure, run [4mwt config shell install[24m[22m[33m▲[39m [33mFound [1mwt[22m in [1m~/.bashrc:2[22m but not detected as integration:[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__explicit_config_path_not_found_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__explicit_config_path_not_found_shows_warning.snapindex 52d87f21f..0148913cd 100644--- a/tests/snapshots/integration__integration_tests__config_show__explicit_config_path_not_found_shows_warning.snap+++ b/tests/snapshots/integration__integration_tests__config_show__explicit_config_path_not_found_shows_warning.snap@@ -12,10 +12,15 @@ info:COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMON_DIR: ""GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_DIR: ""GIT_EDITOR: ""+ GIT_INDEX_FILE: ""+ GIT_OBJECT_DIRECTORY: ""GIT_TERMINAL_PROMPT: "0"+ GIT_WORK_TREE: ""HOME: "[TEST_HOME]"LANG: CLC_ALL: C@@ -31,13 +36,17 @@ info:WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: true@@ -52,4 +61,4 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mConfig file not found: /nonexistent/worktrunk/config.toml[39m+[33m▲[39m [33mConfig file not found: [1m/nonexistent/worktrunk/config.toml[22m[39m