chore: enforce branch, commit and authorship rules via git hooks - #10
Merged
Merged
Conversation
Adds two hooks, activated for every contributor by the `prepare` script pointing core.hooksPath at .githooks/ during `pnpm install`: - pre-commit rejects commits made straight to the clone's default branch, resolved from origin/HEAD so a fork and an upstream clone both work - commit-msg rejects subjects that break Conventional Commits (lowercase type, 72 chars, no trailing period) and messages carrying assistant attribution trailers or footers Merge, revert, fixup!/squash! and release subjects stay exempt so release tooling keeps working. Each rule has an environment escape hatch for the deliberate exception, and --no-verify still skips both. Rules live in one module, covered by 50 tests via `pnpm test:hooks`.
CONTRIBUTING.md gathers the rules the hooks enforce: one branch per issue, Conventional Commits, no assistant attribution in the record, plus the escape hatches and where pull requests go. CLAUDE.md states the same for agent sessions. README points newcomers at both.
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.
Makes three conventions we already follow enforceable for every contributor, rather than documented and hoped for.
What lands
.githooks/— two hooks sharing one rule module, no new dependency:pre-commitrejects a commit made straight to the clone's default branch. It resolves that fromorigin/HEAD, so it guardsdevin the fork andmainin this repo without configuration.commit-msgrejects a subject that breaks Conventional Commits — lowercase type, 72 characters, no trailing period — and any message carrying an assistant attribution trailer or footer.Merge, revert,
fixup!/squash!and release subjects (v1.3.0) stay exempt, so release tooling is untouched. Each rule has an environment escape hatch for the deliberate exception, and--no-verifystill skips both.Activation is a
preparescript pointingcore.hooksPathat.githooks/, sopnpm installsets it up. No husky, no commitlint — the only requirement is the Node you already need.Docs:
CONTRIBUTING.mdfor people,CLAUDE.mdfor agent sessions, and a pointer from the README.Checked against this repo's history
The rules were tuned against the existing 60 commits rather than imposed: 41 subjects were already conventional, the scope pattern allows spaces for
feat(contract verification):, and only one past subject exceeds 72 characters. No commit in history carries an attribution trailer, so nothing needed rewriting.Verification
pnpm test:hooks— 50 tests, unit plus integration that drive the real hooks through realgit commitcalls in a temporary repositorypnpm build,pnpm test,pnpm lintunaffectedTrade-offs
Hooks bind after
pnpm install, and--no-verifybypasses them by design — this is a guardrail, not a gate. A CI job validating PR commits would close both gaps; deliberately left out of this PR, easy to add later if it is wanted.