Skip to content

build: switch pre-commit hooks to prek#250

Merged
wesm merged 2 commits intomainfrom
feat/prek-precommit
Mar 28, 2026
Merged

build: switch pre-commit hooks to prek#250
wesm merged 2 commits intomainfrom
feat/prek-precommit

Conversation

@wesm
Copy link
Copy Markdown
Owner

@wesm wesm commented Mar 28, 2026

Summary

  • Replace hand-rolled .githooks/pre-commit script with prek for managing pre-commit hooks (matching roborev setup)
  • make lint now runs golangci-lint run --fix to auto-fix formatting issues on commit
  • New make lint-ci target preserves the no-fix behavior for CI

Test plan

  • brew install prek && make install-hooks installs the hook
  • prek run --all-files passes
  • Committing triggers the golangci-lint hook with auto-fix

🤖 Generated with Claude Code

Replace the hand-rolled .githooks/pre-commit script with prek, matching
the setup used in roborev. The local hook runs `make lint` which now
includes `--fix` for auto-formatting. A separate `lint-ci` target
preserves the no-fix behavior for CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Mar 28, 2026

roborev: Combined Review (1722785)

Verdict: Changes are mostly sound, but there are 2 medium-severity regressions in hook installation behavior that should be addressed before merge.

Medium

  • Makefile:222
    make install-hooks now runs prek install without -f. In repos that already have the previous pre-commit hook installed, this can fail to replace the existing hook or leave the old hook in place. prek migration guidance requires force-replacing an existing hook during this transition.
    Suggested fix: change this to prek install -f and document that the command replaces any existing hook.

  • Makefile:222
    The previous implementation resolved the active hooks directory with git rev-parse --git-path hooks, which works for linked worktrees and non-default core.hooksPath setups. Replacing that with plain prek install appears to drop that logic, which risks installing into .git/hooks/ instead of the directory Git is actually using.
    Suggested fix: preserve the resolved hook-path behavior, or invoke prek through a wrapper/flow that installs into the path returned by git rev-parse --git-path hooks.


Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

Avoids legacy migration mode where prek would run both the old and new
hook on every commit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci bot commented Mar 28, 2026

roborev: Combined Review (11d5533)

Verdict: Changes are mostly sound, but there is one medium-severity regression in lint target behavior that should be addressed before merge.

Medium

  • make lint now mutates files instead of acting as a check
    Location: Makefile:171
    Changing make lint to golangci-lint run --fix ./... turns a previously read-only validation target into a mutating command. Any CI job or automation still calling make lint can now rewrite files silently and may pass on fixable lint violations instead of failing, which weakens lint enforcement.
    Suggested fix: Keep lint as a non-mutating check target and introduce a separate lint-fix target for local/pre-commit use, or update all existing automated callers to use make lint-ci in the same change.

Synthesized from 3 reviews (agents: codex, gemini | types: default, security)

@wesm
Copy link
Copy Markdown
Owner Author

wesm commented Mar 28, 2026

Invalid

@wesm wesm merged commit f14669c into main Mar 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant