feat(commits): add Conventional Commits message normalizer - #231
Open
iamlasse wants to merge 1 commit into
Open
Conversation
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
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.
What
Standardizes commit messages by enforcing Conventional Commits across the project:
internal/commits— pureNormalizefunction + 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;--checkvalidates 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 existingmake install-hookstarget alongside the pre-commit hook.commit-msgjob inci.ymlvalidating every commit in a PR viago run ./cmd/nightshift commit normalize --check, so enforcement does not depend on the local hook.docs/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 buildcleanNightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift