build: add commit message tooling

Add a repository-local tool to lint, format, and safely reword commit
messages. Preserve markdown lists, quotes, code blocks, and trailers
while enforcing subject and body width limits.

Expose linting, formatting, and rewording through Make targets and
document the supported workflows. Run the linter in CI for pull request
and push commit ranges so malformed messages are caught before merging.
This commit is contained in:
Slyghtning 2026-07-22 14:25:59 +02:00
parent 41bc5f85df
commit eb63b0b4fe
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
4 changed files with 1058 additions and 0 deletions

30
docs/commit-tooling.md Normal file
View file

@ -0,0 +1,30 @@
# Commit Message Tooling
Use `scripts/commit_message.py` to lint, format, and safely reword commit
messages. The script enforces subject/body wrapping (`69`/`72`), keeps real
newlines, and preserves markdown-like body structure (lists, quotes, fenced
blocks, trailers).
## Common Workflows
```bash
# Lint the current commit message
make commitmsg-lint commit=HEAD
# Lint a commit range
make commitmsg-lint range=upstream/master..HEAD
# Format a message file in place
make commitmsg-fmt file=/tmp/msg inplace=1
# Reword a commit from formatted output
make commitmsg-reword commit=<sha>
# Preview a reword without rewriting history
make commitmsg-reword commit=<sha> dryrun=1
```
## Literal Newlines
If a message was created with literal `\n` sequences, use `decode=1` with
`commitmsg-fmt` or `commitmsg-reword` to convert them to real line breaks.