feat: add commit message normalizer (library + commit-normalize subcommand)#177
Open
iamlasse wants to merge 1 commit into
Open
feat: add commit message normalizer (library + commit-normalize subcommand)#177iamlasse wants to merge 1 commit into
iamlasse wants to merge 1 commit into
Conversation
Add a Conventional Commits normalizer exposed as a reusable library (internal/normalizer) and a `commit-normalize` subcommand. Normalization rules: - lowercase the subject line - strip trailing periods - trim leading/trailing whitespace - separate subject and body with a single blank line - enforce the type(scope)!?: subject shape - wrap body paragraphs to <=100 columns (footers kept verbatim) - warn when the subject exceeds 72 characters or lacks a type prefix The subcommand reads a message from a positional file path, --file, or stdin and prints the normalized message, exiting non-zero on empty/invalid input. Logic is covered by table-driven tests. 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 Conventional Commits commit-message normalizer, exposed both as a reusable Go library (
internal/normalizer) and as anightshift commit-normalizesubcommand.Normalization rules
type(scope)!?: subjectshape — lowercases the type/scope, normalizes the colon-space and!breaking marker.Token: value/Token #123) are left verbatim.CLI
nightshift commit-normalizereads a message from a positional file path,--file, or stdin, prints the normalized message to stdout, emits any warnings to stderr, and exits non-zero on empty/invalid input.Tests
Table-driven tests in
internal/normalizer/normalizer_test.gocover: clean input, lowercase + period stripping, scope/breaking-marker normalization, missing type prefix, oversized subject, trailing-whitespace trimming, blank-line insertion, subject/body/footer structure, and empty-input errors. Additional tests assert body wrapping stays <=100 columns and that footers are not wrapped.go build ./...,go vet, andgo test ./...all pass.Assumptions / notes
marcus/nightshiftalready contains a Go module, so this integrates into the existing module (github.com/marcus/nightshift) and follows the established cobra command pattern rather than runninggo mod initor rewritingmain.go.type(scope)prefix and preserve the description's casing, that is a one-line change.SubjectLimit/WrapLimitconstants.Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift