Skip to content

chore: add Conventional Commits message normalizer#180

Open
iamlasse wants to merge 2 commits into
marcus:mainfrom
iamlasse:chore/commit-msg-normalizer-nightshift
Open

chore: add Conventional Commits message normalizer#180
iamlasse wants to merge 2 commits into
marcus:mainfrom
iamlasse:chore/commit-msg-normalizer-nightshift

Conversation

@iamlasse

@iamlasse iamlasse commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Standardizes nightshift's commit messages by enforcing
Conventional Commits across the project.

What's included

  • internal/commits normalizer package — a pure, well-tested Normalize
    function that validates the allowed type, enforces a lowercase subject,
    caps subject length (72), strips trailing periods, and wraps the body at
    72 columns. Normalization is idempotent (Normalize(Normalize(m)) == Normalize(m)).
    Messages that require a human decision (missing/unknown type, missing subject,
    capitalized or overlong subject) are rejected with typed errors.
  • nightshift commit normalize [MESSAGE] command (cmd/nightshift/commands/commit.go)
    — reads a message from a positional arg, --file, or stdin, and rewrites it
    to canonical form. --check validates only; exit code is non-zero when a
    message cannot be normalized.
  • scripts/commit-msg.sh hook — rewrites the commit message file into
    canonical form before the commit is created and rejects non-conforming
    messages with a non-zero exit.
  • make install-hooks — extended to also symlink scripts/commit-msg.sh
    into .git/hooks/commit-msg (and chmod +x it) alongside the existing
    pre-commit hook.
  • Docsdocs/commit-messages.md (format reference), plus README
    Development and AGENTS.md Conventions sections documenting the requirement,
    allowed types, and make install-hooks.
  • Unit tests for the normalizer.

Verification

  • go build ./...
  • go vet ./...
  • go test ./internal/commits/...
  • go test ./... ✓ (all packages)
  • Idempotency confirmed (Normalize applied twice yields identical output).
  • commit normalize --check exits 0 on conforming messages and non-zero on
    non-conforming ones.
  • Hook smoke-tested end-to-end: non-conforming message rejected (exit 1);
    conforming message normalized in place (exit 0).

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


Automated by nightshift

iamlasse added 2 commits June 28, 2026 02:10
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
Extend the Makefile `install-hooks` target to also symlink
`scripts/commit-msg.sh` into `.git/hooks/commit-msg` (and chmod +x it),
alongside the existing pre-commit hook, and fix the target's echo string.
Document the Conventional Commits requirement, allowed types, and the
`make install-hooks` workflow in the README Development section and the
AGENTS.md Conventions section so contributors learn the standardized
format.

Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
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