Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(config show): add visual separator between diff and current config (#850)
Maximilian Roos1cf3a9419760
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rsindex 180d45564..a295b7b2d 100644--- a/src/commands/config/show.rs+++ b/src/commands/config/show.rs@@ -369,7 +369,7 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {// Check for deprecations with show_brief_warning=false (silent mode)// User config is global, not tied to any repository- if let Ok(Some(info)) = worktrunk::config::check_and_migrate(+ let has_deprecations = if let Ok(Some(info)) = worktrunk::config::check_and_migrate(&config_path,&contents,true,@@ -379,7 +379,10 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {) {// Add deprecation details to the output bufferout.push_str(&worktrunk::config::format_deprecation_details(&info));- }+ true+ } else {+ false+ };// Validate config (syntax + schema) and warn if invalidif let Err(e) = toml::from_str::<UserConfig>(&contents) {@@ -393,6 +396,11 @@ fn render_user_config(out: &mut String) -> anyhow::Result<()> {)));}+ // Add "Current config" label when deprecations shown (to separate from diff)+ if has_deprecations {+ writeln!(out, "{}", info_message("Current config:"))?;+ }+// Display TOML with syntax highlighting (gutter at column 0)write!(out, "{}", format_toml(&contents))?;@@ -482,7 +490,7 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {// Check for deprecations with show_brief_warning=false (silent mode)// Only show in main worktree (where .git is a directory)let is_main_worktree = repo_root.join(".git").is_dir();- if let Ok(Some(info)) = worktrunk::config::check_and_migrate(+ let has_deprecations = if let Ok(Some(info)) = worktrunk::config::check_and_migrate(&config_path,&contents,is_main_worktree,@@ -492,7 +500,10 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {) {// Add deprecation details to the output bufferout.push_str(&worktrunk::config::format_deprecation_details(&info));- }+ true+ } else {+ false+ };// Validate config (syntax + schema) and warn if invalidif let Err(e) = toml::from_str::<ProjectConfig>(&contents) {@@ -506,6 +517,11 @@ fn render_project_config(out: &mut String) -> anyhow::Result<()> {));}+ // Add "Current config" label when deprecations shown (to separate from diff)+ if has_deprecations {+ writeln!(out, "{}", info_message("Current config:"))?;+ }+// Display TOML with syntax highlighting (gutter at column 0)write!(out, "{}", format_toml(&contents))?;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.snapindex 47bd502b2..30d90cc49 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@@ -50,6 +50,7 @@ exit_code: 0[107m [0m [36m@@ -1 +1 @@[m[107m [0m [31m-post-create = "ln -sf {{ main_worktree }}/node_modules"[m[107m [0m [32m+[m[32mpost-create = "ln -sf {{ repo }}/node_modules"[m+[2m○[22m Current config:[107m [0m post-create = [32m"ln -sf {{ main_worktree }}/node_modules"[36mSHELL INTEGRATION[39mdiff --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 3acad3d7d..98814cad3 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@@ -49,6 +49,7 @@ exit_code: 0[107m [0m [31m-post-create = "ln -sf {{ repo_root }}/node_modules"[m[107m [0m [32m+[m[32mworktree-path = "../{{ repo }}.{{ branch }}"[m[107m [0m [32m+[m[32mpost-create = "ln -sf {{ repo_path }}/node_modules"[m+[2m○[22m Current config:[107m [0m worktree-path = [32m"../{{ main_worktree }}.{{ branch }}"[107m [0m post-create = [32m"ln -sf {{ repo_root }}/node_modules"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.snapindex 0d2b45899..6c498f59a 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@@ -50,6 +50,7 @@ exit_code: 0[107m [0m [31m-[projects."github.com/example/repo".commit-generation][m[107m [0m [32m+[m[32m[projects."github.com/example/repo".commit.generation][m[107m [0m command = "llm -m gpt-4"[m+[2m○[22m Current config:[107m [0m worktree-path = [32m"../{{ repo }}.{{ branch }}"[107m [0m[107m [0m [1m[36m[projects."github.com/example/repo".commit-generation]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.snapindex a8c630e2c..df9330d2b 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@@ -41,6 +41,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 Current config:[107m [0m post-create = [32m"ln -sf {{ main_worktree }}/node_modules"[36mSHELL INTEGRATION[39mdiff --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 da9bfb53e..f3ddfa934 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@@ -54,6 +54,7 @@ exit_code: 0[107m [0m [32m+[m[32m[commit.generation][m[107m [0m [32m+[m[32mcommand = "claude"[m[33m▲[39m [33mKey [1mcommit-generation[22m belongs in user config (will be ignored)[39m+[2m○[22m Current config:[107m [0m [1m[36m[commit-generation][107m [0m command = [32m"claude"