feat(commits): add breaking-change and commit-msg hook support - #203
Open
iamlasse wants to merge 2 commits into
Open
feat(commits): add breaking-change and commit-msg hook support#203iamlasse wants to merge 2 commits into
iamlasse wants to merge 2 commits into
Conversation
Add internal/commits with pure Normalize/validate functions enforcing the project's Conventional Commits rules (known type set, lowercase type, lowercase subject, 72-char subject limit, whitespace trimming, and 72-column body wrapping). Wire it into the CLI as 'nightshift commit normalize' (positional, --file, and stdin sources; --check to validate only), ship a commit-msg git hook under scripts/, and document the format and installation in docs/commit-messages.md. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
Complete the Conventional Commits normalizer into a fully spec-compliant,
git-hook-ready tool.
* internal/commits: support the Conventional Commits 1.0.0 breaking-change
header indicator ("feat!:" / "fix(api)!:"), preserving the flag through
parseHeader/formatHeader. Recognize the "BREAKING CHANGE:" / "BREAKING-CHANGE:"
footer as a trailer and emit it verbatim instead of hard-wrapping it.
* cmd/nightshift: make --check validate-only (silent on success, single
diagnostic + non-zero exit on failure, never rewriting the file). Make
--file rewrite the message in place when the result differs, so a real
commit-msg hook can normalize the actual commit. Silence cobra usage noise.
* scripts/commit-msg.sh: drive the in-place --file rewrite; hint at the
breaking-change forms in the rejection message.
* Makefile install-hooks: also install the commit-msg hook.
* README: document both hooks and the Conventional Commits enforcement.
* tests: cover "feat!:", "fix(scope)!:", footer preservation and idempotency,
and CLI behavior for --check / in-place --file.
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
Completes the Conventional Commits message normalizer into a fully spec-compliant, git-hook-ready tool. The base normalizer lived only in a local commit (
c26c5fd), not onmain; this PR brings it in and closes the remaining gaps.Changes
internal/commits): parse the Conventional Commits 1.0.0!header indicator (feat!:/fix(api)!:), preserving the flag throughparseHeader/formatHeader. Recognize theBREAKING CHANGE:/BREAKING-CHANGE:footer as a trailer and emit it verbatim instead of hard-wrapping it.--checkfixed (cmd/nightshift): validate-only — silent on success, single diagnostic + non-zero exit on failure, never rewriting the file. Previously it was a no-op that printed the normalized message.--file(cmd/nightshift): default mode rewrites the message file in place, but only when the result differs (no mtime churn on already-canonical messages), so a real commit-msg hook can normalize the actual commit.scripts/commit-msg.sh,Makefile): the commit-msg hook now drives the in-place rewrite and hints at breaking-change forms;make install-hooksinstalls both hooks.README.md): documents both hooks and the Conventional Commits enforcement.feat!:,fix(scope)!:, footer preservation + idempotency, and CLI behavior for--check/ in-place--file.Verification
gofmt,go vet ./...,go build ./..., andgo test ./internal/commits/... ./cmd/nightshift/...all pass.Closes the commit-normalize task.