git-cliff
git-cliff copied to clipboard
Add option to fail on unconventional commits
Is there an existing issue or pull request for this?
- [X] I have searched the existing issues and pull requests
Feature description
An option to fail generating the changelog if the git history contains commits that do not comply to the conventional commits format would allow using git-cliff as a quality gate. Currently additional tools are needed to implement such behaviour.
Desired solution
Add a new configuration parameter:
# fail if the git history contains commits that are not conventional (default: false)
fail_on_unconventional = true
If git-cliff encounters any unconventional commits, it should print the hashes of all unconventional commits to stderr and exit with a non-zero return code. Outputting the commits gives developers a clear indication as to what they need to fix.
$ git-cliff
Encountered unconventional commits: 12345678, abcdefg
Alternatives considered
There exist other tools that can check compliance with conventional commits. However having to use multiple tools bloats the pipeline.
Additional context
No response
Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️
I would change/add to it fail_on_not_matched
to fail if the type/commits were not matched by any of the commit_parsers
(this way it won't collide with other configurations that git-cliff allows us to do)
@MeitarR smart! do you want to give it a shot?
@MeitarR smart! do you want to give it a shot?
Sure, I'll see if I'll make it today (if not then I can't promise when)
Do you have a decision if checking commits is something that will continue?
If so then maybe it should be "strict_mode" and then maybe have its own section on what needs to be checked (in later changes)
It will probably be better that you will decide the direction of this area before we implement it
I think we can start with the strict mode so git-cliff
will exit with return code 1 when the parsing unconventional commits or matching commits fail when fail_on_not_matched
is true...