Skip to content

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.rs
index 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 buffer
out.push_str(&worktrunk::config::format_deprecation_details(&info));
- }
+ true
+ } else {
+ false
+ };
// Validate config (syntax + schema) and warn if invalid
if 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 buffer
out.push_str(&worktrunk::config::format_deprecation_details(&info));
- }
+ true
+ } else {
+ false
+ };
// Validate config (syntax + schema) and warn if invalid
if 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.snap
index 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
  @@ -1 +1 @@
  -post-create = "ln -sf {{ main_worktree }}/node_modules"
  +post-create = "ln -sf {{ repo }}/node_modules"
+○ Current config:
  post-create = "ln -sf {{ main_worktree }}/node_modules"
SHELL INTEGRATION
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 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
  -post-create = "ln -sf {{ repo_root }}/node_modules"
  +worktree-path = "../{{ repo }}.{{ branch }}"
  +post-create = "ln -sf {{ repo_path }}/node_modules"
+○ Current config:
  worktree-path = "../{{ main_worktree }}.{{ branch }}"
  post-create = "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.snap
index 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
  -[projects."github.com/example/repo".commit-generation]
  +[projects."github.com/example/repo".commit.generation]
  command = "llm -m gpt-4"
+○ Current config:
  worktree-path = "../{{ repo }}.{{ branch }}"
 
  [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.snap
index 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
PROJECT CONFIG [PROJECT_ID]
▲ Project config uses deprecated template variables: main_worktree → repo
↳ To generate migration file, run wt config show from main worktree
+○ Current config:
  post-create = "ln -sf {{ main_worktree }}/node_modules"
SHELL INTEGRATION
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 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
  +[commit.generation]
  +command = "claude"
▲ Key commit-generation belongs in user config (will be ignored)
+○ Current config:
  [commit-generation]
  command = "claude"