feat(commits): Conventional Commits normalizer + commit-msg hook#179
Open
iamlasse wants to merge 1 commit into
Open
feat(commits): Conventional Commits normalizer + commit-msg hook#179iamlasse wants to merge 1 commit into
iamlasse wants to merge 1 commit into
Conversation
Add a dependency-free internal/commits package that validates and rewrites commit messages to Conventional Commits form, expose it as `nightshift commit normalize`, and ship an installable commit-msg hook. Parse and preserve the Conventional Commits 1.0.0 breaking-change marker (`feat!:` / `feat(api)!:`). Make the `--check` flag validate-only: it emits an `ok` confirmation instead of rewriting the message, with a non-zero exit on validation failure. 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.
Summary
Adds a reusable, dependency-free Conventional Commits message normalizer, exposed as
nightshift commit normalizeand backed by an installablecommit-msggit hook.This is iteration 2 of the commit-normalize task. It fixes the two defects found in review of the prior attempt:
--checkis no longer a no-op.--checknow validates only — it prints anokconfirmation instead of the rewritten message, and exits non-zero on validation failure. The default (no flag) path still prints the normalized message.feat!:andfeat(api)!:now parse, validate, and re-emit correctly instead of failing with "commit type is not in the allowed set".Changes
internal/commits/normalizer.go— pureNormalizewith table-driven validation (type set, scope,!marker, subject length/capitalization, comment stripping, trailing whitespace/period, 72-col body wrapping).internal/commits/normalizer_test.go— table-driven tests + idempotency, including the breaking-change marker cases.cmd/nightshift/commands/commit.go—nightshift commit normalize [--check] [--file FILE] [MSG].scripts/commit-msg.sh— installable hook (rewrites the message file; rejects unfixable messages; usesmktempfor its scratch file).docs/commit-messages.mdandMakefile(install-hooks) — docs + install wiring.Verification
Closes the commit-normalize task.