-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
feat: configurable commit validation #648
base: master
Are you sure you want to change the base?
feat: configurable commit validation #648
Conversation
674f283
to
f624bd3
Compare
Codecov ReportBase: 97.92% // Head: 98.01% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #648 +/- ##
==========================================
+ Coverage 97.92% 98.01% +0.08%
==========================================
Files 35 39 +4
Lines 1252 1710 +458
==========================================
+ Hits 1226 1676 +450
- Misses 26 34 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
0f30511
to
006026a
Compare
I'm not sure why the patch check is failing - it's complaining about a lack of test code coverage in a file that I didn't touch. |
@@ -79,3 +83,53 @@ def info(self) -> Optional[str]: | |||
elif info: | |||
return info | |||
return None | |||
|
|||
|
|||
class CustomizeCommitValidationCz(CustomizeCommitsCz): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need to add this Cz rule. Could you describe a bit more? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mostly so that I could test it in the unit tests, but also to give others an example to work with if they want to use the feature. I didn't see a better place to put it, if you can suggest one I'm happy to put it somewhere :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of moving it to tests
. Not sure whether it works
Allow clients overriding the BaseCommitizen object to have more custom commit message validation beyond just matching a regex schema. This lets clients have custom error messages and more intelligent pattern matching.
006026a
to
bbe424a
Compare
It seems the latest version didn't pass the CI. @protonjohn could you please take a look? Thanks! |
Allow clients overriding the BaseCommitizen object to have more custom commit message validation beyond just matching a regex schema. This lets clients have custom error messages and more intelligent pattern matching.
Description
This change lets users add certain things like bad word filters or more intelligent task ID listing (for example, make sure one or more IDs appears in the commit message, and in no particular order).
Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and testExpected behavior
Override
validate_commit
orvalidate_commits
inBaseCommitizen
for commit validation functions that are expressible in Python, and not just by a regular expression.Steps to Test This Pull Request
Run the
test_check_custom_validation_succeeds
andtest_check_custom_validation_fails
test cases intests/commands/test_check_command.py
.Additional context
I noticed during my development that the
test_check_command_with_empty_range
case was failing with the error:instead of generating its expected output. I did my best to make sure that this failure wasn't related to my changes, since it also reproduced when I ran the test suite against
master
. It could just be an issue with my local environment.