feat(commits): add breaking-change and commit-msg hook support - #204
Open
iamlasse wants to merge 1 commit into
Open
feat(commits): add breaking-change and commit-msg hook support#204iamlasse wants to merge 1 commit into
iamlasse wants to merge 1 commit into
Conversation
Adds Conventional Commits 1.0.0 breaking-change support (the "!" header indicator and the BREAKING CHANGE: footer), fixes the no-op --check flag so it validates-only with non-zero exit on non-conformance, makes --file mode rewrite the message in place (idempotent, mtime-preserving), and ships a scripts/commit-msg.sh hook plus README/Makefile install docs. Footer handling is generalized beyond BREAKING CHANGE: every paragraph whose first line looks like a git trailer (Signed-off-by:, Co-authored-by:, Fixes #..., Nightshift-Task:, BREAKING CHANGE:, ...) is emitted verbatim, so the commit-msg hook never collapses trailers into prose. Subject length is validated after the trailing period is stripped, and body wrapping measures width in runes so multi-byte subjects cannot overshoot. 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 normalizer (base in a local-only commit) into a fully spec-compliant, git-hook-ready normalizer, addressing iteration-1 review feedback.
Changes
!header indicator (feat!:,fix(api)!:) and theBREAKING CHANGE:/BREAKING-CHANGE:footer.--checkvalidate-only: prints nothing on success, prints the error and exits non-zero on non-conformance (distinct from default mode, which prints the rewritten message).--filerewrite: writes the normalized message back to the file so a realcommit-msghook can enforce the format; only writes when the result differs (mtime-preserving no-op on canonical input).scripts/commit-msg.shhook (diagnostics captured in a per-invocationmktempfile, not a fixed shared path) plus README + Makefile (make install-hooksnow installs both hooks) documentation.feat!:/fix(scope)!:/BREAKING CHANGE:preservation, idempotency of the breaking form,--checkrejection, and trailer preservation.Iteration-2 review fixes
BREAKING CHANGE:. Every paragraph whose first line looks like a git trailer (Signed-off-by:,Co-authored-by:,Fixes #..., this project's ownNightshift-Task:/Nightshift-Ref:, etc.) is emitted verbatim instead of being joined into a wrapped prose paragraph. Verified at runtime — the project's own required trailers now round-trip unchanged..(canonical form 70) is accepted.utf8.RuneCountInString) so multi-byte subjects cannot overshootBodyWrapWidth, matchingMaxSubjectLength.mktemp) instead of a fixed, world-writable, non-unique/tmppath.Verification
gofmt,go vet ./...,go build ./..., andgo test ./internal/commits/... ./cmd/nightshift/commands/...all pass. The localpre-commitandcommit-msghooks both ran on this commit.Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift