-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: validate conventional commits #4122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a great idea. I guess for people with write access, a git-hook would do. For contributors, we can use a custom github action/workflow to validate the commit message(s). For instance a GH action running if [ "${{ github.event_name }}" = "pull_request" ]; then
# For pull requests, check all commits in the PR
git log --format="%H" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | while read commit; do
echo "Validating commit: $commit"
git log --format="%B" -n 1 $commit | npx commitlint --verbose
done
else
# For push events, check the last commit
echo "Validating last commit"
git log --format="%B" -n 1 HEAD | npx commitlint --verbose
fi We can ignore this check for situations, where we squash merge with a re-written commit message. |
Sounds like a good idea. We should encapsulate that logic into a
This one looks like a big dependency though, I don't think we need all the functionality. The bash script on the git hook looked really simple https://github.com/tapsellorg/conventional-commits-git-hook/blob/master/commit-msg-hook.sh. Couldn't we do the same in a python script? To keep it simple, this python script should just process the commit message, it doesn't really have to call WDYT? |
Yes, this should be doable with a simple python script. I'll try to work on this. |
Not sure why we'd roll our own when I think we should just set up |
https://github.com/conventional-changelog/commitlint Do we need that much more? Why so much stuff for parsing a commit message of 72 characters max? A big dependency like that will bring more renovate PRs. I think it's always a good policy to keep dependencies lean and lower upkeep. |
If the |
Examples of rules that could be interesting:
I had previously also written an internal plugin to use imperative mood to start the subject line. See https://www.git-basics.com/docs/git-commit/commit-message-rules for example for rationale behind this.
We should use commitlint from nixpkgs, then it will not cause any more effort. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Sometimes commits can be merged without following conventional commits and the commit messages can slip review.
Recent examples:
Solution
Enforce commits follow conventional commits.
We can do this with a git hook https://github.com/tapsellorg/conventional-commits-git-hook.
Also there's https://github.com/amannn/action-semantic-pull-request for enforcing PR titles -- although is not strictly needed IMO.
Notes
The text was updated successfully, but these errors were encountered: