Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ git commit -m "..." # Reviews happen automatically
roborev tui # View reviews in interactive UI
```

**Note**: Hook installation automatically detects your git hook manager (Husky, etc.) via `core.hooksPath`.

## Commands

| Command | Description |
Expand Down
36 changes: 30 additions & 6 deletions cmd/roborev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,23 @@ func initCmd() *cobra.Command {
return fmt.Errorf("get hooks path: %w", err)
}
hookPath := filepath.Join(hooksDir, "post-commit")
hookContent := `#!/bin/sh

// Get full path to roborev executable to avoid PATH issues in hooks
roborevPath, err := exec.LookPath("roborev")
if err != nil {
roborevPath = "roborev" // Fallback to PATH lookup
}

// Create hook with proper quoting and fallback for moved/upgraded binaries
hookContent := fmt.Sprintf(`#!/bin/sh
# RoboRev post-commit hook - auto-reviews every commit
roborev enqueue --quiet &
`
ROBOREV=%q
if [ ! -x "$ROBOREV" ]; then
ROBOREV=$(command -v roborev) || exit 0
fi
"$ROBOREV" enqueue --quiet &
`, roborevPath)

// Ensure hooks directory exists
if err := os.MkdirAll(hooksDir, 0755); err != nil {
return fmt.Errorf("create hooks directory: %w", err)
Expand Down Expand Up @@ -739,10 +752,21 @@ func installHookCmd() *cobra.Command {
return fmt.Errorf("create hooks directory: %w", err)
}

hookContent := `#!/bin/sh
// Get full path to roborev executable to avoid PATH issues in hooks
roborevPath, err := exec.LookPath("roborev")
if err != nil {
roborevPath = "roborev" // Fallback to PATH lookup
}

// Create hook with proper quoting and fallback for moved/upgraded binaries
hookContent := fmt.Sprintf(`#!/bin/sh
# RoboRev post-commit hook - auto-reviews every commit
roborev enqueue --quiet &
`
ROBOREV=%q
if [ ! -x "$ROBOREV" ]; then
ROBOREV=$(command -v roborev) || exit 0
fi
"$ROBOREV" enqueue --quiet &
`, roborevPath)

if err := os.WriteFile(hookPath, []byte(hookContent), 0755); err != nil {
return fmt.Errorf("write hook: %w", err)
Expand Down
Loading