Skip to content

refactor(alias): remove lazy/eager template expansion branching - #2110

Merged
max-sixty merged 2 commits into
mainfrom
unify-shell-helpers
Apr 12, 2026
Merged

max-sixty merged 2 commits into
mainfrom
unify-shell-helpers

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The lazy/eager distinction in alias template expansion was unnecessary — alias expansion always happens at execution time (in AliasExecCtx::run), so vars.* references naturally read fresh values from git config without special handling. The "lazy" path was round-tripping context_json back to the same HashMap that was serialized from context_map.

Removes the intermediate HashMap<&str, &str>, the is_pipeline field, and the template_references_var branching. Both dry-run and execution paths now route through expand_shell_template, making it the canonical expansion path for all three consumers (hooks, aliases, pipelines).

Follow-up to #2095 and #2103.

This was written by Claude Code on behalf of @max-sixty

Alias expansion always happens at execution time (in AliasExecCtx::run),
so the lazy/eager distinction for vars.* was unnecessary — the "lazy"
path round-tripped context_json back to the same HashMap that was
serialized from context_map. Template freshness for vars.* comes from
the template engine reading git config at expansion time, not from the
context map.

Remove the intermediate HashMap<&str, &str>, the is_pipeline field, and
the template_references_var branching. Both dry-run and execution paths
now route through expand_shell_template, making it the canonical
expansion path for all three consumers (hooks, aliases, pipelines).

Co-Authored-By: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/integration_tests/step_alias.rs:683-686 still describes test_alias_pipeline_lazy_vars as exercising "the lazy re-expansion path in AliasExecCtx::run (which only triggers when is_pipeline && template references vars.)." That path no longer exists after this PR — the test still verifies the right behavior, but the docstring (and arguably the _lazy_ in the test name and the alias_lazy.txt marker) is now misleading. Happy to push a follow-up commit if useful.

The test no longer exercises a "lazy re-expansion path" — update the name
and docstring to describe what it actually verifies.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 66458e8 into main Apr 12, 2026
22 checks passed
@max-sixty
max-sixty deleted the unify-shell-helpers branch April 12, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants