Conversation
PR SummaryLow Risk Overview Adds Reviewed by Cursor Bugbot for commit c81d805. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Tool check runs after index is already modified
- Moved the
golangci-lintavailability check ahead of any stashing, formatting, orgit addwork so the hook fails before mutating state.
- Moved the
- ✅ Fixed: Hook fails on macOS default bash lacking
mapfile- Replaced
mapfilewith a portablewhile readloop so the hook works with macOS's default Bash 3.2.
- Replaced
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit c81d805. Configure here.
| if ! command -v golangci-lint >/dev/null 2>&1; then | ||
| echo "golangci-lint is required for this repo. Install it and retry." >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Tool check runs after index is already modified
Low Severity
The golangci-lint availability check on line 30 runs after gofmt -w and git add have already mutated the working tree and index on lines 27–28. If the tool is missing, the hook exits with an error, but the developer's staged content has been silently reformatted. The pre-flight tool check needs to happen before any index/worktree modifications (i.e., before the gofmt -w / git add block).
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c81d805. Configure here.
| repo_root=$(git rev-parse --show-toplevel) | ||
| cd "$repo_root" | ||
|
|
||
| mapfile -t staged_go_files < <(git diff --cached --name-only --diff-filter=ACM -- "*.go") |
There was a problem hiding this comment.
Hook fails on macOS default bash lacking mapfile
Medium Severity
mapfile is a bash 4.0+ built-in, but macOS ships bash 3.2 (Apple won't update past GPLv2). Running this hook with /usr/bin/env bash on a stock Mac resolves to /bin/bash (3.2), causing an immediate mapfile: command not found error that blocks every Go commit. This is a frequently reported issue in other projects. A while IFS= read -r loop achieves the same result portably.
Reviewed by Cursor Bugbot for commit c81d805. Configure here.


Summary
make install-hooksto install the hook into.git/hooksgofmt,golangci-lint, andgo test ./...before Go commits landTesting
bash -n scripts/pre-commitmake install-hooksGOTOOLCHAIN=go1.26.1 go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8PATH="/tmp/keep-gobin:$PATH" golangci-lint run ./...go test ./...