Skip to content

feat(commits): add Conventional Commits message normalizer - #245

Closed
iamlasse wants to merge 3 commits into
marcus:mainfrom
iamlasse:chore/commit-normalize-20260913
Closed

iamlasse wants to merge 3 commits into
marcus:mainfrom
iamlasse:chore/commit-normalize-20260913

Conversation

@iamlasse

Copy link
Copy Markdown

Summary

Carries forward the Conventional Commits message normalizer originally submitted in #240, re-verified against current main (dc3b319). This PR supersedes the earlier duplicate PRs for this feature so they can be consolidated: #226, #228, #229, #231, #232, #234, #235, #236, #237, and #240. Please review this one and close the others.

Contents (unchanged from #240):

  • internal/commits — pure Normalize/validate: known type set (feat/fix/docs/style/refactor/test/chore/perf/build/ci), lowercased type, 72-char subject, whitespace trim, 72-column body wrap with verbatim git-trailer and structured-line preservation; idempotent
  • nightshift commit normalize CLI — positional/--file/stdin input, --check mode
  • scripts/commit-msg.sh — git commit-msg hook that rewrites the message file in place (or aborts on unrecoverable messages)
  • docs/commit-messages.md — format documentation

Verification (2026-09-13, against main @ dc3b319)

  • go build ./cmd/nightshift — pass
  • go vet ./... — pass
  • gofmt -l . — clean
  • go test ./... — all packages pass (incl. internal/commits)
  • golangci-lint config not yet on main (pending chore(lint): add golangci-lint config and fix the 71 findings it surfaces #241), so lint not run against a config
  • End-to-end smoke test with a freshly built binary:
    • positional / stdin / --file / --check all behave as specified (type lowercased, whitespace trimmed, body wrapped, trailers kept verbatim)
    • scripts/commit-msg.sh installed in a throwaway repo: a real commit's message was rewritten in place (header normalized, body wrapped, max line length exactly 72, Signed-off-by/Nightshift-* trailers preserved on separate lines), and a non-Conventional message was rejected with a non-zero exit aborting the commit
    • Note for reviewers installing locally: the hook prefers a nightshift binary on $PATH; a stale installed version (e.g. v0.3.4 via go install) prints the normalized message to stdout but does not rewrite the file in place — rebuild/reinstall before testing the hook.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift

Add internal/commits with pure Normalize/validate functions enforcing the project's Conventional Commits rules (known type set, lowercase type and 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; --file rewrites the message in place), ship a commit-msg git hook under scripts/ with make install-hooks support, and document the format and installation in docs/commit-messages.md.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
wrapBody used to join every run of consecutive non-blank body lines into
a single paragraph before wrapping, which merged multi-line git trailers
(Signed-off-by, Co-authored-by) onto one line and destroyed intentional
line structure such as lists and indented code blocks. The final
paragraph is now detected as a git trailer block and emitted verbatim,
and structured lines (list items, quotes, indented or fenced code) keep
their own lines while prose around them is still joined and wrapped.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
Bring the PR branch up to date with origin/main (dc3b319, agent
guidance docs refresh). No code changes; keeps the PR current for
review.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
@iamlasse

Copy link
Copy Markdown
Author

Closing as a duplicate: superseded by #248, which contains the complete Commit Message Normalizer implementation (normalizer package, CLI command, commit-msg hook, docs) with review findings addressed.

@iamlasse iamlasse closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant