Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Point deprecation warnings to `wt config update` (#1089)
Maximilian Roosfeb92a624799
diff --git a/src/commands/config/update.rs b/src/commands/config/update.rsindex 4ba890c7a..c4be9c4a0 100644--- a/src/commands/config/update.rs+++ b/src/commands/config/update.rs@@ -85,7 +85,7 @@ pub fn handle_config_update(yes: bool) -> anyhow::Result<()> {fn format_update_preview(info: &DeprecationInfo) -> String {let mut out = format_deprecation_warnings(info);- // Show diff (without the "mv" apply hint that format_deprecation_details adds)+ // Show diff (without the hint that format_deprecation_details adds)if let Some(new_path) = &info.migration_path&& let Some(diff) = format_migration_diff(&info.config_path, new_path){diff --git a/src/config/deprecation.rs b/src/config/deprecation.rsindex 3acfd3cc4..a8e8bd9d4 100644--- a/src/config/deprecation.rs+++ b/src/config/deprecation.rs@@ -29,10 +29,7 @@ use shell_escape::unix::escape;use crate::config::WorktrunkConfig;use crate::shell_exec::Cmd;-use crate::styling::{- eprintln, format_bash_with_gutter, format_with_gutter, hint_message, info_message,- warning_message,-};+use crate::styling::{eprintln, format_with_gutter, hint_message, warning_message};/// Tracks which config paths have already shown deprecation warnings this process./// Prevents repeated warnings when config is loaded multiple times.@@ -766,29 +763,9 @@ pub fn check_and_migrate(}// Still write migration file if needed (first time only)- if !should_skip_write- && let Some(new_path) = write_migration_file(path, content, &info.deprecations, repo)- {- // Show apply hint for first-time migration file write- let new_filename = new_path- .file_name()- .map(|n| n.to_string_lossy())- .unwrap_or_default();- let new_path_str = escape(new_path.to_slash_lossy());- let path_str = escape(path.to_slash_lossy());-- eprintln!(- "{}",- info_message(cformat!(- "Wrote migrated <bold>{new_filename}</>. To apply:"- ))- );- eprintln!(- "{}",- format_bash_with_gutter(&format!("mv -- {} {}", new_path_str, path_str))- );-- info.migration_path = Some(new_path);+ // The file is needed for `wt config update` / `wt config show` to work+ if !should_skip_write {+ info.migration_path = write_migration_file(path, content, &info.deprecations, repo);}std::io::stderr().flush().ok();@@ -810,7 +787,7 @@ pub fn check_and_migrate(/// caller is responsible for output.pub fn format_brief_warning(label: &str) -> String {warning_message(cformat!(- "{} has deprecated settings. To see details, run <bold>wt config show</>",+ "{} has deprecated settings. Run <bold>wt config show</> for details or <bold>wt config update</> to apply updates",label)).to_string()@@ -892,8 +869,8 @@ pub fn format_migration_diff(original_path: &Path, new_path: &Path) -> Option<St/// Format deprecation warning lines (without apply hints or diff).////// Lists which deprecated patterns were found: template variables, config sections,-/// approved-commands. Used by both `format_deprecation_details` (which adds the "mv"-/// hint) and `config migrate` (which applies automatically).+/// approved-commands. Used by both `format_deprecation_details` (which adds the+/// `wt config update` hint and diff) and `wt config update` (which applies directly).pub fn format_deprecation_warnings(info: &DeprecationInfo) -> String {use std::fmt::Write;let mut out = String::new();@@ -988,31 +965,15 @@ pub fn format_deprecation_details(info: &DeprecationInfo) -> String {// Migration hint with apply commandif let Some(new_path) = &info.migration_path {- let new_filename = new_path- .file_name()- .map(|n| n.to_string_lossy())- .unwrap_or_default();- // Shell-escape paths for safe copy/paste- let new_path_str = escape(new_path.to_slash_lossy());- let path_str = escape(info.config_path.to_slash_lossy());-- let _ = writeln!(- out,- "{}",- info_message(cformat!(- "Wrote migrated <bold>{new_filename}</>. To apply:"- ))- );let _ = writeln!(out,"{}",- format_bash_with_gutter(&format!("mv -- {} {}", new_path_str, path_str))+ hint_message(cformat!("Run <bright-black>wt config update</> to apply")));- // Inline diff with intro+ // Inline diff — git diff header shows the file pathsif let Some(diff) = format_migration_diff(&info.config_path, new_path) {- let _ = writeln!(out, "{}", info_message("Diff:"));- let _ = writeln!(out, "{}", diff);+ let _ = writeln!(out, "{diff}");}} else if info.in_linked_worktree {// In linked worktree - migration file is written to main worktree@@ -1020,7 +981,7 @@ pub fn format_deprecation_details(info: &DeprecationInfo) -> String {out,"{}",hint_message(cformat!(- "To generate migration file, run <bright-black>wt config show</> from main worktree",+ "Run <bright-black>wt config update</> from main worktree to apply",)));}diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rsindex 8ae0785bb..1715f0071 100644--- a/tests/integration_tests/config_show.rs+++ b/tests/integration_tests/config_show.rs@@ -1441,9 +1441,8 @@ alias wt="git worktree"/// When a config uses deprecated variables (repo_root, worktree, main_worktree),/// the CLI should:-/// 1. Show a warning listing the deprecated variables and their replacements+/// 1. Show a warning pointing to `wt config show` and `wt config update`/// 2. Create a .new migration file with replacements-/// 3. Show a hint with the mv command to apply the migration#[rstest]fn test_deprecated_template_variables_show_warning(repo: TestRepo, temp_home: TempDir) {// Write config with deprecated variables to the test config path@@ -1548,15 +1547,13 @@ fn test_deprecated_template_variables_hint_deduplication(repo: TestRepo, temp_ho"First run should succeed: {:?}",String::from_utf8_lossy(&output.stderr));- let stderr = String::from_utf8_lossy(&output.stderr);- assert!(- stderr.contains("Wrote migrated"),- "First run should write migration file, got: {stderr}"- );}let migration_file = project_config_path.with_extension("toml.new");- assert!(migration_file.exists());+ assert!(+ migration_file.exists(),+ "First run should create migration file"+ );let original_content = fs::read_to_string(&migration_file).unwrap();@@ -1688,11 +1685,6 @@ fn test_deleted_migration_file_regenerated(repo: TestRepo, temp_home: TempDir) {"Second run should succeed: {:?}",String::from_utf8_lossy(&output.stderr));- let stderr = String::from_utf8_lossy(&output.stderr);- assert!(- stderr.contains("Wrote migrated"),- "Should write migration file when it doesn't exist, got: {stderr}"- );}// Migration file should exist again@@ -1727,12 +1719,11 @@ fn test_fixing_deprecated_config_clears_hint_for_future_deprecations(set_temp_home_env(&mut cmd, temp_home.path());let output = cmd.output().unwrap();assert!(output.status.success());- let stderr = String::from_utf8_lossy(&output.stderr);- assert!(- stderr.contains("Wrote migrated"),- "First run should write migration file"- );}+ assert!(+ project_config_path.with_extension("toml.new").exists(),+ "First run should create migration file"+ );// User fixes the config (removes deprecation)fs::write(@@ -1770,7 +1761,7 @@ fn test_fixing_deprecated_config_clears_hint_for_future_deprecations().unwrap();- // Third run with new deprecation - should get FULL warning (not just brief)+ // Third run with new deprecation - should get full treatment// because hint was cleared when config was clean{let mut cmd = repo.wt_command();@@ -1780,8 +1771,8 @@ fn test_fixing_deprecated_config_clears_hint_for_future_deprecations(assert!(output.status.success());let stderr = String::from_utf8_lossy(&output.stderr);assert!(- stderr.contains("Wrote migrated"),- "New deprecation should get full treatment with file write, got: {stderr}"+ stderr.contains("deprecated settings"),+ "New deprecation should show warning, got: {stderr}");}@@ -1853,7 +1844,7 @@ fn test_deprecated_project_config_silent_in_feature_worktree(repo: TestRepo, tem/// User config migration file write is deduplicated based on file existence./// First run creates the migration file. Subsequent runs skip the write-/// if the file already exists (brief warning only, pointing to `wt config show`).+/// if the file already exists (brief warning only).#[rstest]fn test_user_config_deprecated_variables_deduplication(repo: TestRepo, temp_home: TempDir) {// Write user config with deprecated variables using the test config path@@ -1870,20 +1861,18 @@ fn test_user_config_deprecated_variables_deduplication(repo: TestRepo, temp_homecmd.arg("list").current_dir(repo.root_path());set_temp_home_env(&mut cmd, temp_home.path());let output = cmd.output().unwrap();- let stderr = String::from_utf8_lossy(&output.stderr);assert!(output.status.success(),"First run should succeed: {:?}",- stderr- );- assert!(- stderr.contains("Wrote migrated"),- "First run should write migration file, got: {stderr}"+ String::from_utf8_lossy(&output.stderr));}let migration_file = user_config_path.with_extension("toml.new");- assert!(migration_file.exists());+ assert!(+ migration_file.exists(),+ "First run should create migration file"+ );// Second run - hint is already marked shown, skip file write// Should show brief warning only, NOT regenerate the filediff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_always_regenerates_migration_file.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_always_regenerates_migration_file.snapindex ed638c352..152b77c13 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_always_regenerates_migration_file.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_always_regenerates_migration_file.snap@@ -46,9 +46,7 @@ exit_code: 0[36mPROJECT CONFIG[39m _REPO_/.config/wt.toml[33m▲[39m [33mProject config uses deprecated template variables: [2mmain_worktree[22m → [1mrepo[22m[39m-[2m○[22m Wrote migrated [1mwt.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml-[2m○[22m Diff:+[2m↳[22m [2mRun [90mwt config update[39m to apply[22m[107m [0m [1mdiff --git a_REPO_/.config/wt.toml b_REPO_/.config/wt.toml.new[m[107m [0m [1mindex 8fcdb47..42cb136 100644[m[107m [0m [1m--- a_REPO_/.config/wt.toml[mdiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snapindex 709111775..c78cd4dd9 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap@@ -43,9 +43,7 @@ exit_code: 0----- stderr -----[36mUSER CONFIG[39m ~/.config/worktrunk/config.toml[33m▲[39m [33mUser config uses deprecated template variables: [2mrepo_root[22m → [1mrepo_path[22m, [2mmain_worktree[22m → [1mrepo[22m[39m-[2m○[22m Wrote migrated [1mconfig.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml-[2m○[22m Diff:+[2m↳[22m [2mRun [90mwt config update[39m to apply[22m[107m [0m [1mdiff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new[107m [0m [1mindex d95d100..ceb381d 100644[m[107m [0m [1m--- a[TEMP_HOME]/.config/worktrunk/config.tomldiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snapindex 3ad78a7d2..6910d44b9 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap@@ -43,9 +43,7 @@ exit_code: 0----- stderr -----[36mUSER CONFIG[39m ~/.config/worktrunk/config.toml[33m▲[39m [33mUser config uses deprecated config sections: [projects."github.com/example/repo".commit-generation] → [projects."github.com/example/repo".commit.generation][39m-[2m○[22m Wrote migrated [1mconfig.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml-[2m○[22m Diff:+[2m↳[22m [2mRun [90mwt config update[39m to apply[22m[107m [0m [1mdiff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new[107m [0m [1mindex de80729..131a2fd 100644[m[107m [0m [1m--- a[TEMP_HOME]/.config/worktrunk/config.tomldiff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snapindex 9c4870f36..e8ad9f755 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap@@ -46,7 +46,7 @@ exit_code: 0[36mPROJECT CONFIG[39m [PROJECT_ID][33m▲[39m [33mProject config uses deprecated template variables: [2mmain_worktree[22m → [1mrepo[22m[39m-[2m↳[22m [2mTo generate migration file, run [90mwt config show[39m from main worktree[22m+[2m↳[22m [2mRun [90mwt config update[39m from main worktree to apply[22m[2m○[22m Current config:[107m [0m post-create = [32m"ln -sf {{ main_worktree }}/node_modules"diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snapindex cbb2fe5ba..f09e8d1c2 100644--- a/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap@@ -47,9 +47,7 @@ exit_code: 0[36mPROJECT CONFIG[39m _REPO_/.config/wt.toml[33m▲[39m [33mProject config uses deprecated config sections: [commit-generation] → [commit.generation][39m-[2m○[22m Wrote migrated [1mwt.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml-[2m○[22m Diff:+[2m↳[22m [2mRun [90mwt config update[39m to apply[22m[107m [0m [1mdiff --git a_REPO_/.config/wt.toml b_REPO_/.config/wt.toml.new[m[107m [0m [1mindex 074c30f..bcaf404 100644[m[107m [0m [1m--- a_REPO_/.config/wt.toml[mdiff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_approved_commands_copies_to_approvals_file.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_approved_commands_copies_to_approvals_file.snapindex 60533289e..f9fee5bc8 100644--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_approved_commands_copies_to_approvals_file.snap+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_approved_commands_copies_to_approvals_file.snap@@ -47,7 +47,5 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mUser config has deprecated settings. To see details, run [1mwt config show[22m[39m+[33m▲[39m [33mUser config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39m[2m↳[22m [2mCopied approved commands to [90mapprovals.toml[39m[22m-[2m○[22m Wrote migrated [1mtest-config.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEST_CONFIG_NEW] [TEST_CONFIG]diff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snapindex d53082882..5422ccc66 100644--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_project_level_shows_warning.snap@@ -47,6 +47,4 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mUser config has deprecated settings. To see details, run [1mwt config show[22m[39m-[2m○[22m Wrote migrated [1mtest-config.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEST_CONFIG_NEW] [TEST_CONFIG]+[33m▲[39m [33mUser config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snapindex d53082882..5422ccc66 100644--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_commit_generation_section_shows_warning.snap@@ -47,6 +47,4 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mUser config has deprecated settings. To see details, run [1mwt config show[22m[39m-[2m○[22m Wrote migrated [1mtest-config.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEST_CONFIG_NEW] [TEST_CONFIG]+[33m▲[39m [33mUser config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snapindex d53082882..5422ccc66 100644--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_show_warning.snap@@ -47,6 +47,4 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mUser config has deprecated settings. To see details, run [1mwt config show[22m[39m-[2m○[22m Wrote migrated [1mtest-config.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEST_CONFIG_NEW] [TEST_CONFIG]+[33m▲[39m [33mUser config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39mdiff --git a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snapindex e743aa593..d4555b5a3 100644--- a/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap+++ b/tests/snapshots/integration__integration_tests__config_show__deprecated_template_variables_verbose_shows_content.snap@@ -48,9 +48,7 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 3 ahead----- stderr ------[33m▲[39m [33mUser config has deprecated settings. To see details, run [1mwt config show[22m[39m-[2m○[22m Wrote migrated [1mtest-config.toml.new[22m. To apply:-[107m [0m [2m[0m[2m[34mmv[0m[2m [0m[2m[36m--[0m[2m [TEST_CONFIG_NEW] [TEST_CONFIG]+[33m▲[39m [33mUser config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39m[2m○[22m Expanding [1mworktree-path[22m[107m [0m ../{{ main_worktree }}.{{ branch }} [2m→[22m ../repo.feature-a[2m○[22m Expanding [1mworktree-path[22mdiff --git a/tests/snapshots/integration__integration_tests__config_show__wt_list_skips_migration_file_after_first_write.snap b/tests/snapshots/integration__integration_tests__config_show__wt_list_skips_migration_file_after_first_write.snapindex 25c89654c..728b611b7 100644--- a/tests/snapshots/integration__integration_tests__config_show__wt_list_skips_migration_file_after_first_write.snap+++ b/tests/snapshots/integration__integration_tests__config_show__wt_list_skips_migration_file_after_first_write.snap@@ -24,10 +24,13 @@ info:SHELL: ""TERM: alacrittyUSERPROFILE: "[TEST_HOME]"+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_NUSHELL_ENV: "0"WORKTRUNK_TEST_POWERSHELL_ENV: "0"WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"@@ -44,4 +47,4 @@ exit_code: 0[2m○[22m [2mShowing 4 worktrees, 1 with changes, 3 ahead----- stderr ------[33m▲[39m [33mProject config has deprecated settings. To see details, run [1mwt config show[22m[39m+[33m▲[39m [33mProject config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39m