Skip to content

docs+test(hooks): tighten "(else the primary)" wording; cover the no-config approval path - #2727

Merged
max-sixty merged 1 commit into
mainfrom
config-worktree-source
May 11, 2026
Merged

max-sixty merged 1 commit into
mainfrom
config-worktree-source

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Two small consolidations on top of #2717 (which dropped the residual fallback in the shared collect_remove_hook_commands approval helper, finishing what #2714 started):

Spec tightening. The commands::hooks "Which .config/wt.toml a hook reads" table row for post-merge / post-remove / post-switch after a removal previously read "the destination — for wt merge, the target branch's worktree (else the primary)". Once the fallback rule was gone, "(else the primary)" could be misread as a config fallback. Re-phrased it as the path choice for the destination — the merge target's worktree if one exists, otherwise the primary — explicitly noted "not a config fallback".

Regression test. Added test_remove_no_fallback_to_primary_pre_remove: a worktree with no .config/wt.toml plus a pre-remove in the primary. Before #2717, wt remove without --yes aborted with "needs approval" because the helper surfaced the primary's hook and tests have no TTY; after #2717 the prompt is empty and removal succeeds. #2717's commit message argued the malformed-config tests covered the helper end-to-end, but no test covered the no-config (empty-prompt) path specifically — this fills that gap, so a future re-introduction of the fallback would surface immediately.

Verified twice: stashed project_config.rs to its pre-#2717 state → test fails with exactly the symptom (pre-remove: echo ran > ... shown in the prompt, Cannot prompt for approval in non-interactive environment). Restored → test passes. cargo run -- hook pre-merge --yes is green.

…approval/execution parity

Two small consolidations on top of #2717 (which dropped the fallback in
`collect_remove_hook_commands`):

- **Spec**: the `commands::hooks` table row for `post-merge` /
  `post-remove` / `post-switch` after a removal said "the destination —
  for `wt merge`, the target branch's worktree (else the primary)". With
  fallbacks gone, "(else the primary)" can be misread as a config
  fallback. Re-phrased as the path choice for the destination — the
  merge target's worktree if one exists, otherwise the primary —
  explicitly noting "not a config fallback".

- **Test**: a regression test for the bug #2717 fixed —
  `test_remove_no_fallback_to_primary_pre_remove` exercises a worktree
  with no `.config/wt.toml` while the primary has a `pre-remove`. Before
  #2717, `wt remove` without `--yes` aborted with "needs approval"
  because the helper surfaced the primary's hook and tests have no TTY;
  after #2717 (and with the test in place) the prompt is empty and
  removal succeeds without prompting. #2717 noted that the existing
  malformed-config tests cover the helper end-to-end, but no test
  covered the no-config (empty-prompt) path specifically.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit c67803e into main May 11, 2026
33 checks passed
@max-sixty
max-sixty deleted the config-worktree-source branch May 11, 2026 23:11
@max-sixty max-sixty mentioned this pull request May 13, 2026
max-sixty added a commit that referenced this pull request May 13, 2026
Release v0.50.0.

Highlights:

- Experimental Azure DevOps support (#1256, thanks @mikeyroush; fixes
#1144 from @dlecan) — `wt switch pr:<N>`, `wt list --full`, and `wt
config show --full` recognize Azure DevOps via the `az` CLI.
- Experimental Gitea CI-status detection (#2702) on top of the Gitea
`pr:` shortcut (#1320, thanks @SjB).
- Hooks now resolve `.config/wt.toml` from the worktree they act on —
the primary-worktree fallback is gone, and `post-remove` reads the
removed worktree's config (snapshotted before removal). Approval prompts
collect hook commands from the same worktree. Breaking change for setups
that relied on the primary-worktree fallback; the changelog entry has
the recovery action. (#2690, #2703, #2714, #2717, #2701, #2708, #2727,
#2736, #2748)
- The `wt switch` picker's `alt-r` removal no longer runs unapproved
project hooks (#2746) — the picker's removal path is now routed through
`handle_remove_output` and consults the existing approval state
read-only.
- `wt config alias show` with no name lists every alias's full
definition (#2684, #2691); `wt --help` switches to a compact aliases
pointer (#2688).
- `wt list --branches` warm-run perf: SHA-keyed cache for `main↕` and
`Remote⇅` ahead/behind counts; shared push-remote URL and local-branch
scan (#2704, #2718, #2673).
- Claude Code plugin ships the `wt-switch-create` skill (#2737, thanks
@onetom for #2631).

See `CHANGELOG.md` for the full list (8 Improved, 5 Fixed, 5 Internal).

semver-checks reports breaking library-API changes (new enum variants
without `#[non_exhaustive]`, removed `Branch::github_push_url`, new
trait method on `RemoteRefProvider`), which mandates at minimum a minor
bump pre-1.0.
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