Skip to content

chore: enforce branch, commit and authorship rules via git hooks - #10

Merged
MatiasOS merged 3 commits into
openscan-explorer:mainfrom
MatiasOS:chore/add-git-rules
Sep 9, 2026
Merged

chore: enforce branch, commit and authorship rules via git hooks#10
MatiasOS merged 3 commits into
openscan-explorer:mainfrom
MatiasOS:chore/add-git-rules

Conversation

@MatiasOS

@MatiasOS MatiasOS commented Sep 9, 2026

Copy link
Copy Markdown
Member

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-commit rejects a commit made straight to the clone's default branch. It resolves that from origin/HEAD, so it guards dev in the fork and main in this repo without configuration.
  • commit-msg rejects 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-verify still skips both.

Activation is a prepare script pointing core.hooksPath at .githooks/, so pnpm install sets it up. No husky, no commitlint — the only requirement is the Node you already need.

Docs: CONTRIBUTING.md for people, CLAUDE.md for 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 real git commit calls in a temporary repository
  • pnpm build, pnpm test, pnpm lint unaffected
  • The three commits in this PR were themselves written through the hooks

Trade-offs

Hooks bind after pnpm install, and --no-verify bypasses 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.

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.
@MatiasOS
MatiasOS requested a review from AugustoL September 9, 2026 23:09
@MatiasOS
MatiasOS merged commit f82ee53 into openscan-explorer:main Sep 9, 2026
1 check 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