chore: standardize commit messages on conventional commits - #215
Open
gregggreg wants to merge 3 commits into
Open
chore: standardize commit messages on conventional commits#215gregggreg wants to merge 3 commits into
gregggreg wants to merge 3 commits into
Conversation
Adds a dependency-free POSIX shell commit-msg hook. The normalizer fixes only what it can fix with certainty — trailing whitespace and periods, a capitalized type or leading imperative verb, spacing after the colon, and the blank line before the body — and copies the body and trailers through verbatim. Anything it cannot parse is left alone for the validator to reject with a specific error. Installation stays opt-in: make install-hooks symlinks both hooks into .git/hooks, matching how the existing pre-commit hook is installed, and make uninstall-hooks removes them. No git config is changed implicitly. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
Runs the validator over every commit in the pull request range so a message committed with --no-verify still has to be reworded before the branch is mergeable, and runs the hook's own shell tests. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
Spells out the format, the allowed type list and where it came from, the exemptions, worked good and bad examples, exactly what the normalizer will and will not rewrite, and when --no-verify is legitimate. Adds a CONTRIBUTING.md, which the repository did not have, and links it from the README alongside the updated hook instructions. Existing history is deliberately not rewritten. 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.
What
Standardizes commit messages on Conventional Commits, enforced at two points:
commit-msghook (scripts/commit-msg.sh) that mechanically normalizes safe deviations and rejects what it cannot fix..github/workflows/commit-lint.yml) that validates every commit in a pull request.Everything is dependency-free POSIX shell — no commitlint, no husky, no new runtime dependencies. Hook installation stays opt-in via
make install-hooks, matching howscripts/pre-commit.shis already installed; no developer git config is changed silently.make uninstall-hooksremoves both hooks.Stated assumptions
changelog-synthandrelease-notestasks).feat,fix,docs,chore,test,refactorall appear in the last 200 subjects — plus the rest of the standard set so the vocabulary is not artificially narrow.(#123)is not counted toward the 72-character limit, because GitHub appends it at squash-merge time and authors never type it.Deliberately out of scope
mainwould fail the validator today; that is expected and is not something a hook should retroactively fix.Conservative by design
The normalizer only applies fixes it can make with certainty: trailing whitespace and periods, a capitalized type token, spacing after the colon, a capitalized leading word only when it is on a small allowlist of imperative verbs, and the blank line between subject and body. It copies the body, interior blank lines and trailers through verbatim, never guesses a missing type, and leaves anything it cannot parse alone so the validator can produce a specific error instead. It cannot corrupt a body, drop a trailer, or turn a valid message into an invalid one — e.g.
docs: Nightshift now …keeps its proper noun.Verification
make check(go tests + commit message tests + golangci-lint) passes, andmake test-commit-msgruns 39 shell assertions covering both paths:!preserved; proper noun left alone; blank line inserted and extra blank lines collapsed; body, interior blank lines andNightshift-Task/Co-Authored-Bytrailers preserved verbatim; merge/fixup/Revert "…"and git comments untouchedThe tests pass under
dash,bashandzsh. The hook was also exercised end-to-end in a scratch repository: a fixable message is corrected in place, an unfixable one is rejected with an actionable error, and--no-verifybypasses it. The three commits on this branch conform to the new standard.Note
There are older open PRs from earlier passes at this task (#212, #202). This one supersedes them; close whichever you do not want.
🤖 Generated with Claude Code