Repository navigation
chore(pre-commit): set default_install_hook_types so install arms both stages - #1221
Conversation
…h stages default_stages already lists pre-commit and pre-push, but without default_install_hook_types a plain `pre-commit install` only writes .git/hooks/pre-commit, so the pre-push stage (go test, frontend build and jest) never runs locally unless the developer remembers `pre-commit install -t pre-commit -t pre-push`. Declare both hook types next to default_stages and update the two in-file comments that told developers to pass --hook-type pre-push. Closes LeanerCloud#234 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 1 billable file and costs up to $0.25. Or wait 59 minutes for your next included review. View limit details
Comment |
|
Independent review 2 (claude-fleet, cold): APPROVE 6d4955b Findings (none blocking):
Attacked:
Verified locally, in throwaway
Reviewed by an independent agent with no author context (second reviewer). Review only: nothing was pushed, and the GitHub review state is unchanged. |
|
VERDICT: APPROVE 6d4955b No findings. Issue #234 check: the PR adds Attacked:
|
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 1 approving independent review(s) on |
Root cause
.pre-commit-config.yamlsetsdefault_stages: [pre-commit, pre-push]but notdefault_install_hook_types. pre-commit'sinstallonly writes the hook types listed there, and the default is[pre-commit]. So a plainpre-commit installcreates only.git/hooks/pre-commit. The pre-push stage (go-test,frontend-build,frontend-test, plus every default-stage hook re-run on push) never runs locally unless the developer rememberspre-commit install -t pre-commit -t pre-push.Fix
default_install_hook_types: [pre-commit, pre-push]next todefault_stages, as the issue asks.# Setup:header, and the pre-push block comment that told developers to runpre-commit install --hook-type pre-push.I checked the other places that might give hook-install instructions (README.md, docs/DEVELOPMENT.md, CLAUDE.md, Makefile). None of them tell developers to run
pre-commit install -t ..., and there is noinstall-hookstarget, so nothing else needed changing.make pre-commitis an unrelated make target (fmt/vet/complexity/unit tests).Closes #234
Verification
This is a config-only change, so the evidence comes from running real pre-commit in a throwaway clone, not from a Go test. I used pre-commit 4.0.1 (the version
.github/workflows/pre-commit.ymlpins) in a throwaway venv, with an isolatedHOME/PRE_COMMIT_HOME, andcore.hooksPathunset. Nothing was installed into the real worktree.Fail before (clone of origin/main @ 5d4ab6b):
Pass after (same clone, hooks removed, this branch's
.pre-commit-config.yamlcopied in):Acceptance criteria and other hooks that apply to this file:
Secret scanning:
git secrets --scan .pre-commit-config.yamlcame back clean in a freshgit initrepo with an isolated HOME, using the patterns fromscripts/setup-git-secrets.shand.gitallowed.bash scripts/test-git-secrets-allowlist.shgave 109 PASS, 0 FAIL.No Go code changed, so build/vet/golangci-lint/gocyclo/
internal/mocksguards don't apply.scripts/test-actionlint-hook.shextracts only theactionlinthook from this file, so the new top-level key doesn't affect it.Notes / out of scope
.github/workflows/pre-commit.ymlrunspre-commit run --all-files, which ignores install hook types.pre-commit install(or a re-run on an existing clone),git pushnow runs the pre-push stage. That includesgo test -short -race ./...and the frontend build/jest whenfrontend/src/changed. This is what the issue intends. Existing clones keep their current hooks until someone re-runspre-commit install.default_install_hook_typesneeds pre-commit >= 2.18.0. Older versions warn about an unknown key and fall back to installing only the pre-commit hook. I didn't addminimum_pre_commit_version, to keep the change to what the issue asked for.Maintainer: please mirror the issue's triage labels onto this PR:
impact/internal,type/chore,triaged,priority/p3,severity/low,urgency/eventually,effort/xs.🤖 Generated with Claude Code