Skip to content

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.rs
index 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.rs
index 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 command
if 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 paths
if 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.rs
index 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_home
cmd.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 file
diff --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.snap
index 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
PROJECT CONFIG _REPO_/.config/wt.toml
▲ Project config uses deprecated template variables: main_worktree → repo
-○ Wrote migrated wt.toml.new. To apply:
-  mv -- _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml
-○ Diff:
+↳ Run wt config update to apply
  diff --git a_REPO_/.config/wt.toml b_REPO_/.config/wt.toml.new
  index 8fcdb47..42cb136 100644
  --- a_REPO_/.config/wt.toml
diff --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.snap
index 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 -----
USER CONFIG ~/.config/worktrunk/config.toml
▲ User config uses deprecated template variables: repo_root → repo_path, main_worktree → repo
-○ Wrote migrated config.toml.new. To apply:
-  mv -- [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml
-○ Diff:
+↳ Run wt config update to apply
  diff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new
  index d95d100..ceb381d 100644
  --- a[TEMP_HOME]/.config/worktrunk/config.toml
diff --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.snap
index 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 -----
USER CONFIG ~/.config/worktrunk/config.toml
▲ User config uses deprecated config sections: [projects."github.com/example/repo".commit-generation] → [projects."github.com/example/repo".commit.generation]
-○ Wrote migrated config.toml.new. To apply:
-  mv -- [TEMP_HOME]/.config/worktrunk/config.toml.new [TEMP_HOME]/.config/worktrunk/config.toml
-○ Diff:
+↳ Run wt config update to apply
  diff --git a[TEMP_HOME]/.config/worktrunk/config.toml b[TEMP_HOME]/.config/worktrunk/config.toml.new
  index de80729..131a2fd 100644
  --- a[TEMP_HOME]/.config/worktrunk/config.toml
diff --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.snap
index 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
PROJECT CONFIG [PROJECT_ID]
▲ Project config uses deprecated template variables: main_worktree → repo
-↳ To generate migration file, run wt config show from main worktree
+↳ Run wt config update from main worktree to apply
○ Current config:
  post-create = "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.snap
index 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
PROJECT CONFIG _REPO_/.config/wt.toml
▲ Project config uses deprecated config sections: [commit-generation] → [commit.generation]
-○ Wrote migrated wt.toml.new. To apply:
-  mv -- _REPO_/.config/wt.toml.new _REPO_/.config/wt.toml
-○ Diff:
+↳ Run wt config update to apply
  diff --git a_REPO_/.config/wt.toml b_REPO_/.config/wt.toml.new
  index 074c30f..bcaf404 100644
  --- a_REPO_/.config/wt.toml
diff --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.snap
index 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
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config has deprecated settings. To see details, run wt config show
+▲ User config has deprecated settings. Run wt config show for details or wt config update to apply updates
↳ Copied approved commands to approvals.toml
-○ Wrote migrated test-config.toml.new. To apply:
-  mv -- [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.snap
index 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
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config has deprecated settings. To see details, run wt config show
-○ Wrote migrated test-config.toml.new. To apply:
-  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. Run wt config show for details or wt config update to apply updates
diff --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.snap
index 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
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config has deprecated settings. To see details, run wt config show
-○ Wrote migrated test-config.toml.new. To apply:
-  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. Run wt config show for details or wt config update to apply updates
diff --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.snap
index 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
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config has deprecated settings. To see details, run wt config show
-○ Wrote migrated test-config.toml.new. To apply:
-  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. Run wt config show for details or wt config update to apply updates
diff --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.snap
index 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
○ Showing 4 worktrees, 3 ahead
----- stderr -----
-▲ User config has deprecated settings. To see details, run wt config show
-○ Wrote migrated test-config.toml.new. To apply:
-  mv -- [TEST_CONFIG_NEW] [TEST_CONFIG]
+▲ User config has deprecated settings. Run wt config show for details or wt config update to apply updates
○ Expanding worktree-path
  ../{{ main_worktree }}.{{ branch }} → ../repo.feature-a
○ Expanding worktree-path
diff --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.snap
index 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: alacritty
USERPROFILE: "[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
○ Showing 4 worktrees, 1 with changes, 3 ahead
----- stderr -----
-▲ Project config has deprecated settings. To see details, run wt config show
+▲ Project config has deprecated settings. Run wt config show for details or wt config update to apply updates