Rationalizing hooks
From #1571 — creating a new issue to track
Updated analysis using
startinstead ofcreateto avoid thepost-createcollision. Hooks ordered by lifecycle stage, withpost-commitadded.Current hooks mapped to the new scheme
Current name Current behavior Proposed name Proposed behavior Impact post-createblocking pre-startblocking Rename only — same semantics post-startbackground post-startbackground No change pre-switchblocking pre-switchblocking No change post-switchbackground post-switchbackground No change pre-commitblocking pre-commitblocking No change (none) — post-commitbackground New hook pre-mergeblocking pre-mergeblocking No change post-mergeblocking (Warn) post-mergebackground Behavior change pre-removeblocking pre-removeblocking No change post-removebackground post-removebackground No change The pattern
Every lifecycle event gets a symmetric
pre-(blocking) /post-(background) pair:
Event pre-(blocking)post-(background)start pre-start(waspost-create)post-startswitch pre-switchpost-switchcommit pre-commitpost-commit(new)merge pre-mergepost-merge(was blocking)remove pre-removepost-removeSummary
- 7 unchanged:
post-start,pre-switch,post-switch,pre-commit,pre-merge,pre-remove,post-remove- 1 easy rename:
post-create→pre-start(still blocking, same semantics)- 1 new hook:
post-commit— runs in the background afterwt commitcompletes. Useful for things like triggering CI, notifications, or background linting- 1 behavior change:
post-merge— currently blocks (with Warn failure strategy), would become background under thepost-= background ruleMigration
Only one hook needs migration:
post-create→pre-start. Accept both names for one release cycle with a deprecation warning.The
post-mergebehavior change remains the main design decision:
- Accept the change —
post-mergebecomes background. Users who need blocking can move logic to a script that runs before removal- Add an exception — keep
post-mergeblocking, breaking the cleanpre=blocking, post=backgroundrule- Drop
post-merge— less common hook; users can use external git hooks instead
Originally posted by @worktrunk-bot in #1571
Thanks for extracting this from #1571 — the proposal is well-structured.
I searched the codebase and confirmed none of the proposed changes are implemented yet. Current state:
HookTypeenum (src/git/mod.rs:318-340) defines all 9 hooksHooksConfig(src/config/hooks.rs) maps them to TOML config with kebab-case serialization- Execution strategy is
FailFastfor allpre-hooks andpost-create,Warnforpost-merge, and background forpost-start/post-switch/post-remove
Related issues
- #1571 — Original discussion on hook naming clarity
- #1617 — Requests a blocking
post-switchhook (for copying gitignored files on switch). This conflicts with the proposedpost-= background rule. Worth considering whether this use case needs a different mechanism or an exception.
I'll leave it for a maintainer to evaluate the design decisions, particularly the post-merge behavior change and how #1617's use case fits into the pattern.
Thanks for this @max-sixty - it looks nice, and much easier to reason about