Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: underline each variable name individually in template error hints (#2028)
Maximilian Roosaefb33321932
diff --git a/src/config/expansion.rs b/src/config/expansion.rsindex 0c390c985..7afa0aeda 100644--- a/src/config/expansion.rs+++ b/src/config/expansion.rs@@ -237,10 +237,15 @@ impl std::fmt::Display for TemplateExpandError {parts.push(format_with_gutter(line, None));}if !self.available_vars.is_empty() {+ let underlined_vars: Vec<String> = self+ .available_vars+ .iter()+ .map(|v| cformat!("<underline>{}</>", v))+ .collect();parts.push(hint_message(cformat!(- "Available variables: <underline>{}</>",- self.available_vars.join(", ")+ "Available variables: {}",+ underlined_vars.join(", "))).to_string(),);@@ -770,7 +775,7 @@ mod tests {assert_snapshot!(err, @"[31m✗[39m [31mFailed to expand test: undefined value @ line 1[39m[107m [0m echo {{ target }}- [2m↳[22m [2mAvailable variables: [4mbranch, remote[24m[22m+ [2m↳[22m [2mAvailable variables: [4mbranch[24m, [4mremote[24m[22m");}diff --git a/tests/snapshots/integration__integration_tests__eval__eval_template_error.snap b/tests/snapshots/integration__integration_tests__eval__eval_template_error.snapindex bbff5d3d1..f350814ac 100644--- a/tests/snapshots/integration__integration_tests__eval__eval_template_error.snap+++ b/tests/snapshots/integration__integration_tests__eval__eval_template_error.snap@@ -47,4 +47,4 @@ exit_code: 1----- stderr -----[31m✗[39m [31mFailed to expand eval: undefined value @ line 1[39m[107m [0m {{ undefined_var }}-[2m↳[22m [2mAvailable variables: [4mbranch, commit, cwd, default_branch, main_worktree, main_worktree_path, primary_worktree_path, remote, remote_url, repo, repo_path, repo_root, short_commit, upstream, worktree, worktree_name, worktree_path[24m[22m+[2m↳[22m [2mAvailable variables: [4mbranch[24m, [4mcommit[24m, [4mcwd[24m, [4mdefault_branch[24m, [4mmain_worktree[24m, [4mmain_worktree_path[24m, [4mprimary_worktree_path[24m, [4mremote[24m, [4mremote_url[24m, [4mrepo[24m, [4mrepo_path[24m, [4mrepo_root[24m, [4mshort_commit[24m, [4mupstream[24m, [4mworktree[24m, [4mworktree_name[24m, [4mworktree_path[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snapindex 68bad4277..e17d20473 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_upstream_template.snap@@ -49,4 +49,4 @@ exit_code: 1[33m▲[39m [33mProject config has deprecated settings. Run [1mwt config show[22m for details or [1mwt config update[22m to apply updates[39m[31m✗[39m [31mFailed to expand project pre-start hook: undefined value @ line 1[39m[107m [0m echo 'Upstream: {{ upstream }}' > upstream.txt-[2m↳[22m [2mAvailable variables: [4mbase, base_worktree_path, branch, commit, cwd, default_branch, hook_type, main_worktree, main_worktree_path, primary_worktree_path, remote, remote_url, repo, repo_path, repo_root, short_commit, worktree, worktree_name, worktree_path[24m[22m+[2m↳[22m [2mAvailable variables: [4mbase[24m, [4mbase_worktree_path[24m, [4mbranch[24m, [4mcommit[24m, [4mcwd[24m, [4mdefault_branch[24m, [4mhook_type[24m, [4mmain_worktree[24m, [4mmain_worktree_path[24m, [4mprimary_worktree_path[24m, [4mremote[24m, [4mremote_url[24m, [4mrepo[24m, [4mrepo_path[24m, [4mrepo_root[24m, [4mshort_commit[24m, [4mworktree[24m, [4mworktree_name[24m, [4mworktree_path[24m[22mdiff --git a/tests/snapshots/integration__integration_tests__step_relocate__relocate_template_error.snap b/tests/snapshots/integration__integration_tests__step_relocate__relocate_template_error.snapindex da78320f7..b6cad0791 100644--- a/tests/snapshots/integration__integration_tests__step_relocate__relocate_template_error.snap+++ b/tests/snapshots/integration__integration_tests__step_relocate__relocate_template_error.snap@@ -48,5 +48,5 @@ exit_code: 0[33m▲[39m [33mSkipping [1mfeature[22m due to template error:[39m[31m✗[39m [31mFailed to expand worktree-path: undefined value @ line 1[39m[107m [0m {{ nonexistent_variable }}-[2m↳[22m [2mAvailable variables: [4mbranch, main_worktree, repo, repo_path[24m[22m+[2m↳[22m [2mAvailable variables: [4mbranch[24m, [4mmain_worktree[24m, [4mrepo[24m, [4mrepo_path[24m[22m[2m○[22m No relocations performed; 1 skipped due to template error