Repository navigation
refactor: unify lazy template expansion and concurrent-group waits - #2095
Merged
Merged
Conversation
Extracts two helpers in command_executor.rs to consolidate duplication left over from PR #2089: - `expand_shell_template` replaces three lazy-expansion sites (hooks, aliases, pipeline runner) and the eager sibling in `expand_commands`, so every shell-command template expansion flows through one helper. - `wait_first_error` drains a sequence of Result items and returns the first error, letting alias's `thread::scope` block and the pipeline runner's concurrent group share "wait all, return first error" semantics over different concurrency primitives. Also folds `expand_now` and `build_step_context_json` in run_pipeline.rs into a single `step_context` helper returning `Cow`, eliminating a per-step double-clone of the context map. The concurrent-group bail format now matches the serial-step format ("command failed with {exit}: {label}"), removing a minor inconsistency. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 11, 2026
max-sixty
added a commit
that referenced
this pull request
Apr 11, 2026
Resolves conflicts with #2095 (refactor: unify lazy template expansion and concurrent-group waits) which independently: - Added `wait_first_error` and `expand_shell_template` helpers in command_executor.rs - Refactored AliasExecCtx::run and the alias concurrent block - Refactored run_concurrent_group to use the new helpers Resolution: - alias.rs: combine my serial-test branch with main's `wait_first_error` scaffolding (the non-serial path now delegates to it) - run_pipeline.rs: my serial branch sits inside the per-command loop; the concurrent path uses the merged helpers (`step_context`, `expand_shell_template`, `wait_first_error`) Co-Authored-By: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 11, 2026
Last call site still inlining the `&str` map conversion — fold onto the helper introduced in #2095. Co-Authored-By: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 12, 2026
Last call site still inlining the `&str` map conversion — fold onto the `expand_shell_template` helper introduced in #2095. Follow-up from #2095 session-ending list. > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Apr 12, 2026
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_ --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small follow-ups to #2089, which unified shell command execution for hooks and aliases but left some duplication on the template-expansion and concurrent-wait paths.
What changed
expand_shell_template(insrc/commands/command_executor.rs) — one helper that builds the&strvars map and callsexpand_templatewithshell_escape=true. Replaces three lazy-expansion sites (foreground hooks, background pipeline runner, alias runner) and the eager sibling insideexpand_commands, so every shell template expansion now flows through one helper.wait_first_error(same file) — drains a sequence ofResult<(), E>items and returns the first error. Alias'sthread::scopeblock and the pipeline runner's concurrent group now share "wait all, return first error" semantics over different concurrency primitives (in-process threads vs OS subprocesses). The concurrent-group bail format now matches the serial-step format (command failed with {exit}: {label}), removing a minor inconsistency — per-command output already lives in each command's log file.step_contextinrun_pipeline.rs— foldsexpand_nowandbuild_step_context_jsoninto one helper returningCow<HashMap<String, String>>. Unnamed steps borrow the base context; named steps clone once and inserthook_name. Previously, named steps cloned twice (once for expansion, once for JSON).Where to look
src/commands/command_executor.rs— two new helperssrc/commands/hooks.rs— deleted localexpand_lazy_templatesrc/commands/alias.rs— concurrent block andAliasExecCtx::runsrc/commands/run_pipeline.rs—step_context,run_concurrent_group,expand_commandsin main loopTesting
cargo run -- hook pre-merge --yesis green: 3025/3025 insta-nextest tests, pre-commit lints, doctests,cargo doc. No snapshots changed.