Repository navigation
refactor(hooks): make HookAnnouncer the single entry point - #2484
Merged
Merged
Conversation
Drops the `Option<&mut HookAnnouncer<'_>>` plumbing through `commit.rs::commit`, `step_commands::handle_squash`, `output/handlers.rs::handle_remove_output` and its sub-handlers, and the multi-target prune loop in `step_commands::step_prune`. Each function now takes `&mut HookAnnouncer<'_>` unconditionally; standalone callers (`wt commit`, `wt step squash`, `wt remove`, `wt step prune`, `wt switch` picker post-remove) construct a local announcer and flush right after, while multi-phase callers (`wt merge`) keep their existing single-announcer-per-command pattern. `run_hooks_background` is now a module-private helper of `HookAnnouncer::flush` (was `pub(crate)`). `hook_commands::run_post_hook` also routes through `HookAnnouncer` so flush is the only path that reaches the announce/spawn primitive. `RemovedWorktreeOutputContext` loses its now-redundant `show_branch_in_hooks` field — callers configure the announcer directly. No behavior change: combined announce lines, log paths, `show_branch` semantics, and exit codes are unchanged. Existing snapshots and the full integration suite (3399 tests) pass. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
approved these changes
Apr 30, 2026
…ckground # Conflicts: # src/commands/commit.rs # src/commands/step_commands.rs # src/main.rs
worktrunk-bot
approved these changes
Apr 30, 2026
2 tasks done
This was referenced Apr 30, 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.
Builds on #2477 and #2482. Drops the
Option<&mut HookAnnouncer<'_>>plumbing throughcommit.rs::commit,step_commands::handle_squash,output/handlers.rs::handle_remove_output(and its four sub-handlers), and the multi-target prune loop instep_commands::step_prune. Each function now takes&mut HookAnnouncer<'_>unconditionally — the if/else around "share with caller's announcer or self-announce" is gone. Standalone callers (wt commit,wt step squash,wt remove,wt step prune,wt switchpicker post-remove) construct a local announcer and flush right after; multi-phase callers (wt merge) keep their existing single-announcer-per-command pattern.run_hooks_backgroundis now a module-private helper ofHookAnnouncer::flush(waspub(crate)).hook_commands::run_post_hookalso routes throughHookAnnouncer, soflushis the only path that reaches the announce/spawn primitive.RemovedWorktreeOutputContextloses its now-redundantshow_branch_in_hooksfield — callers configure the announcer directly when constructing it.No behavior change: combined announce lines, log paths,
show_branchsemantics for batch contexts (prune, multi-target remove), and exit codes are all unchanged. Existing snapshots and the full integration suite (3399 tests) pass;cargo run -- hook pre-merge --yesis green.