docs: standardize commit message format - #226
Open
gregggreg wants to merge 2 commits into
Open
Conversation
Codify Conventional Commits as the repository standard: a convention guide, a commit template, a commit-msg hook validator, a range validator reused by a commit-lint CI job, and shell tests for the validator. Enforcement covers new commits only. Existing history is not rewritten, so merged pull requests and released tags keep their current SHAs. Agent prompts now request a conforming subject while preserving the Nightshift-Task and Nightshift-Ref trailers. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
The commit-msg hook sized subjects with `wc -c` and body lines with awk's length(), both of which count bytes. A 71-character subject containing accents, an em-dash, smart quotes, or emoji was rejected as over-long, so the effective limit for non-ASCII text was well under 72. False rejections in a hook that blocks every commit push people toward --no-verify, which erodes the convention this hook exists to enforce. Measure with `wc -m` under a UTF-8 locale instead, probing for a locale the machine actually has. macOS awk reports length() in bytes even in a UTF-8 locale, so awk cannot be used for this. Body-length errors also reported awk's line number from the internally stripped message. git does not strip the comment block before running commit-msg, and `make install-hooks` installs an 18-line comment template, so "body line 3" pointed at line 21 of the author's editor buffer. Tag each line with its original number while stripping and report that. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
Author
|
Addressed the two review findings in `scripts/commit-msg.sh` (fa7b592):
Also documented that limits are character counts and that the body hard limit is 100 (wrap at 72), with trailers and single-token URLs exempt. Regression tests added — the suite is now 45 checks, all passing. One test uses a body line that is 100 characters but 191 bytes, so it fails if byte counting ever returns. |
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.
Codifies the commit format the repo already mostly follows — Conventional Commits — as a documented, enforced standard.
About 129 of 171 commits on
main(~75%) already conform. This makes that explicit for new work.History is not rewritten
No
filter-branch, no rebase of published commits. Merged PRs and released tags keep their SHAs. Enforcement applies to new commits only:commit-msghook checks what you write locally (opt-in viamake install-hooks)commit-lintCI job checks only the commits unique to a PR, computed fromgit merge-baseagainst the base ref — historical drift onmainis left aloneWhat's here
docs/guides/commit-messages.md.gitmessage.txtgit commitopens with the format inlinescripts/commit-msg.shcommit-msghookscripts/check-commit-range.shmake lint-commitsscripts/commit-msg_test.shPlus:
make install-hooksnow installs both hooks and sets the template; newmake test-scriptsandmake lint-commitstargets; acommit-lintCI job; cross-references fromAGENTS.md(andCODEX.md, which symlinks to it) andREADME.md; aCHANGELOG.mdentry.Format
Subject ≤72 chars, no trailing period, imperative mood. Types:
featfixdocsrefactortestchorebuildciperfstylerevert.The validator deliberately passes through subjects git authors itself (
Merge …,Revert …,fixup!,squash!) and accepts acronym-initial subjects (fix: JSONL parsing …), trailers, and long URLs in the body.--no-verifybypasses the hook locally.Agent-authored commits
internal/orchestrator/orchestrator.gonow states the subject format in both the plan and implement prompts, keeping the existingNightshift-Task/Nightshift-Reftrailers intact.orchestrator_test.golocks that contract down.Verification
gofmt -l .— cleango build ./...,go vet ./...— passgo test ./...— all packages passmake test-scripts— 40/40 passStandardize commit messages, then accepted this PR's own commitcheck-commit-range.shverified in both directions (flags a known-drifted historical range, passes this branch)Note on overlap
There is an earlier open PR #186 from a previous run of this task, based on
docs-backfillrather thanmain. It takes a rewrite-in-place approach (scripts/normalize-commit-message.sh); this PR validates and rejects instead, which keeps authorship of the message with the committer. Only one of the two should land — closing #186 in favor of this one is the suggested path.Nightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift