-
-
Notifications
You must be signed in to change notification settings - Fork 288
refactor(check): rename variable and compile pattern once #1470
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
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.87% 97.87%
==========================================
Files 57 57
Lines 2677 2677
==========================================
Hits 2620 2620
Misses 57 57
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)
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.
got it. make sense. let's merge it 🙂
1d49c0b
to
c23c261
Compare
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