-
-
Notifications
You must be signed in to change notification settings - Fork 287
refactor(check): rename variable and compile pattern once #1470
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
base: refactors
Are you sure you want to change the base?
refactor(check): rename variable and compile pattern once #1470
Conversation
eac0d6f
to
37d65a2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## refactors #1470 +/- ##
============================================
Coverage ? 97.82%
============================================
Files ? 57
Lines ? 2618
Branches ? 0
============================================
Hits ? 2561
Misses ? 57
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
37d65a2
to
0b02dbd
Compare
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 somewhat worried about this one. I guess there might been users actually use the message to check. Probably could make it a deprecated thing and change in v5
Then let me revert the |
0b02dbd
to
a53ef4d
Compare
a53ef4d
to
7a5dfb9
Compare
Fixed. You meant the error message, right? |
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 I get the purpose of this PR after the changes. It seems the pattern only compiles once before this PR. or is there anywhere else I missed?
7a5dfb9
to
8932925
Compare
8932925
to
1d49c0b
Compare
if self.max_msg_length: | ||
msg_len = len(commit_msg.partition("\n")[0].strip()) | ||
if msg_len > self.max_msg_length: | ||
return False | ||
return bool(re.match(pattern, commit_msg)) |
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 I get the purpose of this PR after the changes. It seems the pattern only compiles once before this PR. or is there anywhere else I missed?
@Lee-W Before this change, each self._validate_commit_message
evaluates re.match(pattern, _)
once, where re.match
compiles the input string every time.
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.
Hence self.cz.schema_pattern()
is compiled len(commits)
times (assuming no early return)
Description
Checklist
Code Changes
poetry all
locally to ensure this change passes linter check and testsExpected Behavior
Steps to Test This Pull Request
Run
cz check --message "<random strings>"
to check if the error message works like before.Additional Context