New job to give feedback on git commit messages
I am a big believer in writing good git commit messages as explained in e.g. https://optimizedbyotto.com/post/good-git-commit/#a-polished-git-commit-is-always-worth-the-effort
I have witnessed over and over that there is a strong correlation between code base quality deteriorating and code documentation being neglected.
There exist some tools that can be used to automatically give authors feedback on their commit messages:
- https://github.com/Seravo/gnitpick (Python, last commit 3 months ago)
- https://github.com/bkuhlmann/git-lint (Ruby, last commit yesterday)
- https://github.com/jorisroovers/gitlint (Python, last commit 2 years ago, packaged in Debian and PyPI)
However, I am not sure if these are fit for CI usage. In CI the result must be a binary pass/fail, which works for the git commit message only if there is some obvious error in the message, such as a trailing dot in the subject line, no empty line between subject and body, or an overly long message (30+ lines long). Frequently the commit message has something that is ugly but not strictly wrong, for example lines not being wrapped correctly. For those cases it would be too harsh to fail the CI, and a better solution would be just an automated comment sent to the author etc.
Some things are also opinionated. For example, many people love the conventional commit style, but personally I dislike it as I find not using a capital letter to start a title looks ugly, and the extra labeling often makes the human-readable part less informative. I prefer reading commit messages following the classic style as described in the Git Pro book and which typically convey the purpose of the change better.
Automatic linting of git messages is also very mechanical. A message could fully meet all external standards, yet be useless to humans if it failed to explain why a change was made. Automatic linters are also totally incapable of detecting when the text is simply messy or illogical like in the examples at https://optimizedbyotto.com/post/git-commit-message-examples/.
Still, maybe providing some git linting might be useful, so I posted this issue for comments.
Related: #147