Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
Lee-W merged 1 commit into commitizen-tools:refactors from bearomorphism:refactor-check-2
Jun 8, 2025

Conversation

@bearomorphism
Copy link
Contributor

@bearomorphism bearomorphism commented May 30, 2025
edited
Loading

Description

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Expected Behavior

Steps to Test This Pull Request

Run cz check --message "<random strings>" to check if the error message works like before.

Additional Context

Copy link

codecov bot commented May 30, 2025
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.87%. Comparing base (a9cd957) to head (c23c261).
Report is 8 commits behind head on refactors.

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 
Flag Coverage Δ
unittests 97.87% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Lee-W Lee-W left a 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

Copy link
Contributor Author

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 capitalized part of this PR.

Copy link
Contributor Author

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

Fixed. You meant the error message, right?

@bearomorphism bearomorphism changed the title (削除) refactor(check): capitalize error message, rename variable (削除ここまで) (追記) refactor(check): rename variable and compile pattern once (追記ここまで) May 31, 2025
Copy link
Member

@Lee-W Lee-W left a 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?

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))
Copy link
Contributor Author

@bearomorphism bearomorphism Jun 8, 2025

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.

Lee-W reacted with thumbs up emoji
Copy link
Contributor Author

@bearomorphism bearomorphism Jun 8, 2025

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)

Lee-W reacted with thumbs up emoji
Copy link
Member

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 🙂

@Lee-W Lee-W merged commit a272305 into commitizen-tools:refactors Jun 8, 2025
18 checks passed
@bearomorphism bearomorphism deleted the refactor-check-2 branch June 13, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Lee-W Lee-W Lee-W approved these changes

@woile woile Awaiting requested review from woile

@noirbizarre noirbizarre Awaiting requested review from noirbizarre

Assignees

No one assigned

Projects

None yet

Milestone

4.8.3

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /