feat: Add post-hook support for start and checkout commands#22
Conversation
Add configurable post_start_hook and post_checkout_hook to .gwrc, enabling users to integrate with tmux, iTerm2, or any custom workflow after worktree creation. Includes example hook scripts. Inspired by #20 (thanks @pnikonowicz). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22 +/- ##
==========================================
+ Coverage 88.37% 88.68% +0.30%
==========================================
Files 29 30 +1
Lines 1832 1882 +50
==========================================
+ Hits 1619 1669 +50
Misses 173 173
Partials 40 40
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
PR Review: feat/post-hooks This is a clean, well-structured addition. The hook abstraction is minimal and correct, test coverage is solid, and the failure-as-warning behaviour is exactly right. A few issues worth addressing before merging. Bug: Stale comment implies In Inconsistency:
Nit: Unnecessary intermediate variable
Gap: Hooks can't be configured via the interactive editor The test comment acknowledges this: No execution timeout A misbehaving hook that blocks on input will hang Security note: example script path injection In What is working well
The core feature is solid. The |
Cover hook execution path and hook failure warning behavior for both StartCommand and CheckoutCommand. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Code Review: feat: Add post-hook support for start and checkout commandsOverall this is a clean, well-scoped feature with solid test coverage. The design is backward-compatible and the hook-failure-as-warning behavior is the right call. A few issues worth addressing before merging: Bug: Inconsistent
|
| Issue | Severity |
|---|---|
worktreePath not resolved to absolute in start hook |
Bug |
Misleading // "end" comment in hook.go |
Minor |
repoNameForHook unnecessary alias |
Nit |
| iTerm2 script breaks on paths with single quotes | Minor |
| No hook timeout | Design consideration |
The path inconsistency is the one concrete bug — everything else is polish. Great feature overall.
🤖 Generated with Claude Code
- Remove stale "end" from hook command comment (not yet implemented) - Remove unnecessary intermediate variable repoNameForHook - Use filepath.Abs for worktreePath in start command to match checkout behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
post_start_hookandpost_checkout_hookoptions to.gwrcsh -cwith environment variables (GW_WORKTREE_PATH,GW_BRANCH_NAME,GW_REPO_NAME,GW_COMMAND)examples/hooks/for tmux and iTerm2Inspired by #20 (thanks @pnikonowicz).
Closes #20
Test plan
make checkpasses (lint + all tests)post_start_hook = echo ...fires aftergw start🤖 Generated with Claude Code