feat: Add Husky git hook manager support#11
Merged
wesm merged 5 commits intoroborev-dev:mainfrom Jan 9, 2026
Merged
Conversation
Resolve roborev executable path at hook installation time using exec.LookPath() to avoid PATH issues in git hook environments. Benefits: - Fixes hooks in environments where PATH is not fully set - Works with any hook manager (Husky, lefthook, etc.) - Upstream git.GetHooksPath() already handles hook manager detection Changes: - Update initCmd() to resolve full roborev path - Update installHookCmd() to use full path - Add brief README note about automatic detection Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
ca0ef95 to
bf33137
Compare
Testing roborev auto-review with real agent. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Remove extra tab added by mistake on line 257. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Address PR feedback:
1. **Shell escaping (Medium)**: Use %q format specifier to properly
quote the roborev path, handling spaces and special characters.
2. **Stale path fallback (Low)**: Add runtime check that falls back
to 'command -v roborev' if the hardcoded path is moved/upgraded.
Generated hook now:
- Sets ROBOREV variable with quoted path
- Checks if path exists and is executable
- Falls back to PATH lookup if not
- Properly quotes $ROBOREV when executing
Example generated hook:
```bash
#!/bin/sh
ROBOREV="/path/to/roborev"
if [ ! -x "$ROBOREV" ]; then
ROBOREV=$(command -v roborev) || exit 0
fi
"$ROBOREV" enqueue --quiet &
```
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
wesm
approved these changes
Jan 9, 2026
andyxhadji
pushed a commit
to andyxhadji/roborev
that referenced
this pull request
Jan 9, 2026
## Summary
Fixes roborev hooks not working in repositories that use Husky or other
git hook managers. The issue occurred because hooks couldn't find the
`roborev` executable in their minimal PATH environment.
## Problem
When testing roborev on a repository using Husky, automatic reviews
never triggered. Two issues were discovered:
1. **Husky compatibility**: Upstream's `git.GetHooksPath()` already
handles this correctly by respecting `core.hooksPath`, but hooks were
still failing
2. **PATH issue**: Git hooks run with a minimal environment where
`roborev` (installed via `go install` in `$GOPATH/bin`) wasn't in PATH,
causing silent failures
## Solution
Use `exec.LookPath("roborev")` at hook installation time to resolve and
embed the full executable path in the hook:
```bash
# Before (fails if roborev not in PATH)
roborev enqueue --quiet &
# After (always works)
/Users/user/.local/bin/roborev enqueue --quiet &
```
**Why this works for Husky**: The upstream `git.GetHooksPath()` already
handles Husky detection automatically by reading `core.hooksPath` git
config. Our change just ensures the hook content works once it's
installed in the right location.
## Testing
Tested successfully on repo that uses Husky:
- ✅ Hook correctly installed to `.husky/post-commit` (via existing
`git.GetHooksPath()`)
- ✅ Hook uses full path
- ✅ Auto-review triggered on commit (Job 7 completed successfully)
Also tested on repo with no Husky:
- ✅ Hook installed to `.git/hooks/post-commit`
- ✅ Auto-reviews working (Jobs 5 & 6 completed)
## Changed files
- `cmd/roborev/main.go` - Add `exec.LookPath()` resolution in
`initCmd()` and `installHookCmd()`
- `README.md` - Add note about automatic hook manager detection
## Breaking Changes
None. Existing installations continue to work. New installations get
more reliable hooks that work with Husky and similar tools.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.5 <[email protected]>
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.
Summary
Fixes roborev hooks not working in repositories that use Husky or other git hook managers. The issue occurred because hooks couldn't find the
roborevexecutable in their minimal PATH environment.Problem
When testing roborev on a repository using Husky, automatic reviews never triggered. Two issues were discovered:
git.GetHooksPath()already handles this correctly by respectingcore.hooksPath, but hooks were still failingroborev(installed viago installin$GOPATH/bin) wasn't in PATH, causing silent failuresSolution
Use
exec.LookPath("roborev")at hook installation time to resolve and embed the full executable path in the hook:Why this works for Husky: The upstream
git.GetHooksPath()already handles Husky detection automatically by readingcore.hooksPathgit config. Our change just ensures the hook content works once it's installed in the right location.Testing
Tested successfully on repo that uses Husky:
.husky/post-commit(via existinggit.GetHooksPath())Also tested on repo with no Husky:
.git/hooks/post-commitChanged files
cmd/roborev/main.go- Addexec.LookPath()resolution ininitCmd()andinstallHookCmd()README.md- Add note about automatic hook manager detectionBreaking Changes
None. Existing installations continue to work. New installations get more reliable hooks that work with Husky and similar tools.
🤖 Generated with Claude Code