Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(alias): show project aliases with retired template variables migrated (#4690)
Worktrunk Botc60d061ccc59
diff --git a/src/commands/alias.rs b/src/commands/alias.rsindex 2bc2abb8f..a781dec44 100644--- a/src/commands/alias.rs+++ b/src/commands/alias.rs@@ -885,14 +885,15 @@ fn render_aliases_help_section(/// Callers (`augment_help`, `wt config alias show`) latch/// `suppress_warnings()` before reaching here so the standard `UserConfig::load()`/// stays quiet: no deprecation warnings, no `.new` file writes, no-/// approved-commands copy. Project config is parsed directly from TOML rather-/// than via `ProjectConfig::load` because the `aliases` table has no deprecated-/// forms — skipping the migration avoids the unrelated warnings entirely.+/// approved-commands copy. Project config is migrated and parsed directly+/// rather than via `ProjectConfig::load`, avoiding its diagnostic side+/// effects; the migration rewrites retired template variables, so both+/// sources show the template that runs.////// Tolerates missing or unloadable config: this is a discovery surface, not/// an execution surface, so we'd rather show the built-in commands than/// error out when a repo isn't detected or a config file is malformed.-/// `step_alias` surfaces those errors at execution time.+/// Running the alias surfaces those errors.pub(crate) fn load_aliases_for_listing() -> Vec<(String, CommandConfig, HookSource)> {let repo = Repository::current().ok();let project_id = repo.as_ref().and_then(|r| r.project_identifier().ok());@@ -923,7 +924,7 @@ pub(crate) fn load_aliases_for_listing() -> Vec<(String, CommandConfig, HookSourentries}-/// Parse `.config/wt.toml` directly, extracting just `aliases`, without+/// Migrate and parse `.config/wt.toml`, extracting just `aliases`, without/// triggering `ProjectConfig::load`'s deprecation warning and hint-writing/// side effects. See `load_aliases_for_listing` for why.fn load_project_aliases_silent(repo: &Repository) -> Option<BTreeMap<String, CommandConfig>> {@@ -932,7 +933,8 @@ fn load_project_aliases_silent(repo: &Repository) -> Option<BTreeMap<String, Comreturn None;}let contents = std::fs::read_to_string(&path).ok()?;- let config: ProjectConfig = toml::from_str(&contents).ok()?;+ let migrated = worktrunk::config::migrate_content(&contents);+ let config: ProjectConfig = toml::from_str(&migrated).ok()?;Some(config.aliases)}diff --git a/tests/integration_tests/step_alias.rs b/tests/integration_tests/step_alias.rsindex 5fa9d5b02..4fa2925b5 100644--- a/tests/integration_tests/step_alias.rs+++ b/tests/integration_tests/step_alias.rs@@ -1970,6 +1970,31 @@ command = "echo message"}}+/// Project and user aliases display the templates that run: a retired+/// template variable shows as its replacement in both sources, matching the+/// migration execution applies.+#[rstest]+fn test_config_alias_show_migrates_retired_template_vars(repo: TestRepo) {+ repo.write_project_config(+ r#"+[aliases]+open = "code {{ repo_root }}"+"#,+ );+ repo.commit("Add alias config");+ repo.write_test_config(+ r#"+[aliases]+here = "echo {{ worktree }}"+"#,+ );++ let settings = setup_snapshot_settings(&repo);+ let _guard = settings.bind_to_scope();++ assert_cmd_snapshot!(make_snapshot_cmd(&repo, "config", &["alias", "show"], None));+}+/// `wt config alias show` with no name and no aliases configured prints a note/// rather than empty output.#[rstest]diff --git a/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_migrates_retired_template_vars.snap b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_migrates_retired_template_vars.snapnew file mode 100644index 000000000..e90cea4a2--- /dev/null+++ b/tests/snapshots/integration__integration_tests__step_alias__config_alias_show_migrates_retired_template_vars.snap@@ -0,0 +1,66 @@+---+source: tests/integration_tests/step_alias.rs+info:+ program: wt+ args:+ - config+ - alias+ - show+ env:+ APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"+ CLICOLOR_FORCE: "1"+ COLUMNS: "500"+ GIT_ALLOW_PROTOCOL: file+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"+ GIT_AUTHOR_EMAIL: [email protected]+ GIT_AUTHOR_NAME: Test User+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"+ GIT_COMMITTER_EMAIL: [email protected]+ GIT_COMMITTER_NAME: Test User+ GIT_CONFIG_COUNT: "2"+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig+ GIT_CONFIG_KEY_0: user.useConfigOnly+ GIT_CONFIG_KEY_1: rerere.enabled+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig+ GIT_CONFIG_VALUE_0: "true"+ GIT_CONFIG_VALUE_1: "false"+ GIT_TERMINAL_PROMPT: "0"+ HOME: "[TEST_HOME]"+ LANG: C+ LC_ALL: C+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"+ PATH: "[PATH]"+ TERM: alacritty+ USERPROFILE: "[TEST_HOME]"+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"+ WORKTRUNK_TEST_BASH_INSTALLED: "0"+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"+ WORKTRUNK_TEST_EPOCH: "1735776000"+ WORKTRUNK_TEST_FISH_INSTALLED: "0"+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"+ WORKTRUNK_TEST_NUSHELL_ENV: "0"+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"+ WORKTRUNK_TEST_PARENT_SHELL: ""+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"+---+success: true+exit_code: 0+----- stdout -----+[2m○[22m Alias [1mhere[22m (user):+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m{{[0m[2m worktree_path [0m[2m[32m}}[0m+[2m○[22m Alias [1mopen[22m (project):+[107m [0m [2m[0m[2m[34mcode[0m[2m [0m[2m[32m{{[0m[2m repo_path [0m[2m[32m}}[0m++----- stderr -----