Repository navigation
feat: add directional template vars to all two-worktree hooks - #1655
Merged
Merged
Conversation
Adds `cwd`, `target_worktree_path`, and expands `base`/`target` vars to all hook types that involve two worktrees. This is Phase 1 of the template variable redesign — non-breaking additions only, no existing behavior changes. New variables: - `cwd`: execution directory, always exists on disk (all hooks) - `target_worktree_path`: target worktree path (merge and remove hooks) - `target` + `target_worktree_path`: added to pre-remove and post-remove hooks - `base` + `base_worktree_path`: added to pre-switch hooks - `target` + `target_worktree_path`: added to pre-switch (when dest exists) These directional vars follow the "Active" model where each operation has a base (source/origin) and target (destination) side. Phase 2 will change bare var semantics to consistently point to the Active worktree. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
Collaborator
There was a problem hiding this comment.
The template variable table and prose in the hook docs need updating to reflect this PR's changes. Three issues:
targetdescription says "merge hooks only" — now also available in pre-remove, post-remove, and pre-switch (when target worktree exists).base/base_worktree_pathsay "creation hooks only" — now also available in pre-switch.- New variables
cwdandtarget_worktree_pathare missing from the table entirely. - The prose paragraph at line 1310 (
"target", "base", and "base_worktree_path" are hook-specific") should mentioncwdandtarget_worktree_pathtoo.
These are the primary source (src/cli/mod.rs after_long_help) — the docs and skill files auto-sync from them.
Update hook docs to reflect that `target`, `target_worktree_path`, `base`, and `base_worktree_path` are now available in more hook types, and add the new `cwd` variable to the table. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
added a commit
that referenced
this pull request
Mar 22, 2026
The review-pr skill assumed the prior bot review was always APPROVED when skipping trivial incremental changes. When the prior review was COMMENTED (requesting changes), the bot said "existing approval stands" but no approval existed, leaving the PR without bot approval. Extract LAST_REVIEW_STATE alongside LAST_REVIEW_SHA in the preflight, and after resolving threads on trivial follow-ups, submit an approval when the prior state was non-APPROVED. Evidence: 2 occurrences (PR #1655 run 23401754507, plus 1 historical). Co-Authored-By: Claude Opus 4.6 <[email protected]>
3 tasks
max-sixty
added a commit
that referenced
this pull request
Mar 22, 2026
Follow-up fixes and documentation for the template variable redesign (#1655, #1660). **Code fixes:** - `commit` derivation now uses `rev-parse <branch>` instead of `rev-parse HEAD`, so `{{ commit }}` follows the Active branch - `base` / `base_worktree_path` now available in post-switch for existing switches (previously only creates) - post-remove `{{ target }}` now correctly resolves to the destination branch, not the removed branch **Documentation:** - Restructured template variable table — Active vars grouped first, directional vars second, repo-level vars last - Added arrive/depart table explaining what bare vars, `base`, and `target` point to per operation - Documented when `cwd` differs from `worktree_path` (pre-switch existing, post-remove, post-merge with removal) **Tests:** 4 new integration tests for directional var semantics. Ref #1633 > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude <[email protected]>
4 tasks done
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.
Phase 1 of the template variable redesign discussed in #1633. Adds directional vars (
base,target,target_worktree_path,cwd) to all two-worktree hooks — non-breaking additions only, no existing behavior changes.New variables
cwd— execution directory, always exists on disk (all hooks). Enables the Active model in Phase 2 whereworktree_pathbecomes identity rather than execution context.target_worktree_path— target worktree path, added alongside existingtargetfor merge hooks (pre-merge, post-merge) and remove hooks (pre-remove, post-remove).base/base_worktree_path— source branch/worktree, added to pre-switch hooks. For existing destinations,target/target_worktree_pathare also provided.These follow the "Active" model where each two-worktree operation has a base (source/origin) and target (destination) side:
base= where you came from.target= where it's going.Mnemonic: "Are you going there, or is it going away?"
Phase 2 (separate PR) will change bare var semantics so
worktree_pathconsistently points to the Active worktree, withcwdas the execution-context escape hatch.Ref #1633