Skip to content

feat(commits): add Conventional Commits message normalizer - #231

Open
iamlasse wants to merge 1 commit into
marcus:mainfrom
iamlasse:chore/commit-normalize-20260826
Open

feat(commits): add Conventional Commits message normalizer#231
iamlasse wants to merge 1 commit into
marcus:mainfrom
iamlasse:chore/commit-normalize-20260826

Conversation

@iamlasse

Copy link
Copy Markdown

What

Standardizes commit messages by enforcing Conventional Commits across the project:

  • internal/commits — pure Normalize function + table-driven tests. Enforces the allowed type set (feat fix docs style refactor perf test build ci chore revert), optional scope, lowercase imperative subject ≤ 72 chars with no trailing period, git-comment stripping, 72-column body wrapping, and verbatim preservation of trailer blocks (Signed-off-by, Nightshift-Task, …). Idempotent: Normalize(Normalize(m)) == Normalize(m).
  • nightshift commit normalize — CLI command reading from a positional arg, --file (for the commit-msg hook), or stdin; --check validates only and is CI-friendly.
  • scripts/commit-msg.sh — commit-msg git hook that rejects non-conforming messages and rewrites the message file into canonical form. Installed by the existing make install-hooks target alongside the pre-commit hook.
  • CI — new commit-msg job in ci.yml validating every commit in a PR via go run ./cmd/nightshift commit normalize --check, so enforcement does not depend on the local hook.
  • Docsdocs/commit-messages.md (format, rules, examples, hook install) plus a README development-section update.

Existing history is untouched; only future commits are validated (fixable issues are auto-normalized, human decisions are rejected with a clear error).

Testing

  • go test ./... green (includes 16 new table-driven cases: valid/invalid headers, trailers, wrapping, idempotency, allowed types)
  • gofmt/go vet/go build clean
  • Hook verified end-to-end: non-conventional message → commit aborted with actionable error; conforming message → committed in canonical form

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

Add internal/commits with a pure Normalize function enforcing the
project's Conventional Commits rules: known type set (feat, fix, docs,
style, refactor, perf, test, build, ci, chore, revert), optional scope,
lowercase imperative subject limited to 72 chars with no trailing
period, comment stripping, body wrapping at 72 columns, and verbatim
preservation of git trailer blocks. Wire it into the CLI as 'nightshift
commit normalize' (positional, --file, and stdin sources; --check
validates only), ship a commit-msg hook under scripts/, install it via
'make install-hooks', and add a CI job that validates every commit in a
pull request. Document the format in docs/commit-messages.md.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
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