Repository navigation
refactor(hooks): adopt TemplateVars in remaining call sites - #2481
Merged
Merged
Conversation
`commit.rs`, `step_commands::handle_squash`, `picker::do_removal`, and `hook_commands::build_manual_hook_extra_vars` were still building hook extra-vars by hand with `Vec<(&str, &str)>` literals or `to_posix_path` + tuple wrangling. They now use `TemplateVars` like the rest of the hook call sites, which owns the strings and centralizes the `worktree_path`/`worktree` alias. `build_manual_hook_extra_vars` becomes `build_manual_hook_template_vars` and returns `TemplateVars` so callers can extend with bindings (CLI shorthand, `args` JSON) before materializing. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
previously approved these changes
Apr 29, 2026
worktrunk-bot
left a comment
Collaborator
There was a problem hiding this comment.
codecov/patch is failing at 91.66% (44/48 added lines covered) vs the 96.73% project baseline. The misses are llvm-cov reformatting artifacts — same control flow as before, but the new shape exposes coverage points that the original lazy-iterator and one-line-call expressions hid. Specifics:
commit.rs:176(template_vars = template_vars.with_target(target)) — the inside of the newif let Some(target)only fires whenCommitOptions::target_branch == Some(_), which no test exercises. The pre-refactor.into_iter().map(...).collect()chain rendered the same uncovered path as a single covered line.hook_commands.rs:129(None => TemplateVars::new()) — the explicitNonearm is unreachable in tests (default_branch is alwaysSomein fixtures). The pre-refactor.into_iter().map(...).collect()collapsed both arms into one always-hit line.commit.rs:233andstep_commands.rs:351— the trailing)?;of the multi-linespawn_background_hooks(...)call. llvm-cov assigns this region to the?error-propagation branch, which fires 0 times when the call succeeds; the pre-refactor one-line call had no separate region.
Suggestions below collapse each to a single expression, restoring the prior coverage shape. Fixing all four lines should bring patch coverage to 100%.
worktrunk-bot
dismissed
their stale review
April 29, 2026 23:44
codecov/patch is failing — see follow-up review for the four uncovered lines and inline fixes.
Auto-reviewer flagged 4 codecov misses on the previous commit — all artifacts of llvm-cov region splitting on the new multi-line shapes rather than real coverage gaps. Collapsing to single expressions restores the pre-refactor coverage shape: - `commit.rs::commit`: `if let` over `target_branch` → `map_or_else` (one expression covers both arms). - `hook_commands.rs::build_manual_hook_template_vars`: same for the `default_branch` match arm. - `commit.rs` and `step_commands.rs::handle_squash`: bind `template_vars.as_extra_vars()` to a local before calling `spawn_background_hooks`, so the call fits on one line and llvm-cov doesn't split out the trailing `)?;` as an unhit error-propagation region. No behavior change. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 29, 2026
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.
Follow-up to #2472. Four sites still built hook extra-vars by hand:
commit.rs,step_commands::handle_squash,picker::do_removal, andhook_commands::build_manual_hook_extra_vars. They now useTemplateVarslike the rest of the hook call sites — owning the strings and centralizing theworktree_path/worktreealias.build_manual_hook_extra_varsis renamed tobuild_manual_hook_template_varsand returnsTemplateVarsso the two callers (run_hook,expand_command_template) can append CLI bindings or{{ args }}before materializing. Drops two redundantto_posix_pathcalls along the way.Module docstring on
template_vars.rsupdated to reflect that the struct now covers all hook call sites, not just switch/merge.