Skip to content

chore: add commit message normalizer and validator - #186

Draft
gregggreg wants to merge 1 commit into
marcus:mainfrom
gregggreg:nightshift/commit-normalize
Draft

chore: add commit message normalizer and validator#186
gregggreg wants to merge 1 commit into
marcus:mainfrom
gregggreg:nightshift/commit-normalize

Conversation

@gregggreg

@gregggreg gregggreg commented Jul 15, 2026

Copy link
Copy Markdown

Standardizes commit messages on Conventional Commits with a documented convention, an opt-in git hook, and CI enforcement.

Format

type(scope)!: summary

Types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test. Scope and ! are optional. Subjects are lowercase imperative, no more than 72 chars, no trailing period, blank line before the body.

What's here

File Purpose
docs/commit-conventions.md The convention, in full
scripts/commit-msg-lib.sh Shared parsing helpers (bash 3.2 compatible)
scripts/normalize-commit-msg.sh Rewrites a message file in place
scripts/validate-commit-msg.sh One diagnostic line per violated rule
.githooks/commit-msg Normalize, then validate
scripts/install-hooks.sh make install-hooks -> git config core.hooksPath .githooks
tests/commit-msg-test.sh 49 table-driven checks, no framework
.github/workflows/commit-lint.yml Runs the suite and validates every subject the PR adds

Opt-in, and conservative by design

Hooks are opt-in via core.hooksPath - nothing changes for contributors who don't run make install-hooks. CI still checks every PR, so enforcement doesn't depend on local setup.

Normalization only rewrites what is mechanically safe: whitespace, casing of a recognized type, a trailing period, and the subject/body blank line. It never invents a type unless you explicitly pass --infer. Merge, revert, fixup!/squash!/amend!, stash subjects, and comment-only templates are passed through untouched - a hook that blocks git merge is worse than an inconsistent history.

Git's scissors marker and everything below it are copied through byte for byte, so a git commit -v diff can never leak into the commit body. An end-to-end test drives a real git commit -v through the installed hook and asserts the stored message.

Verification

  • ./tests/commit-msg-test.sh - 49/49 pass on bash 3.2 (macOS system bash)
  • go build ./... and go test ./... - clean
  • The new scissors and end-to-end cases were confirmed to fail against the pre-fix normalizer

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift

Generated with Claude Code

@gregggreg
gregggreg force-pushed the nightshift/commit-normalize branch from 7530169 to ea52342 Compare July 15, 2026 09:14
@gregggreg gregggreg changed the title chore: normalize commit messages chore: add commit message normalizer and validator Sep 6, 2026
Standardize on Conventional Commits: a documented convention, a bash
normalizer/validator pair behind an opt-in commit-msg hook, and a CI job
that validates every commit subject a pull request adds.

Normalization is conservative and only rewrites what is mechanically safe
(whitespace, casing of a recognized type, a trailing period, subject/body
separation). Type inference stays behind an explicit --infer flag, and
git-generated subjects (merge, revert, fixup/squash/amend, stash) plus
comment-only templates are never rewritten or rejected.

Git's scissors marker and everything below it are passed through byte for
byte so `git commit -v` diffs cannot leak into the commit body.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
@gregggreg
gregggreg force-pushed the nightshift/commit-normalize branch from a818f1a to c8ebf07 Compare September 6, 2026 10:07
@gregggreg
gregggreg changed the base branch from docs-backfill to main September 6, 2026 10:07
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