-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix(message): protect the message regex check #260
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
fix(message): protect the message regex check #260
Conversation
Protect the "regex" key check by first verifying that the check type is "message". Previously check_commit_msg was verifying that all check configuration structures had valid regex keys. This is unnecessary and does not follow the pattern of other checks. Signed-off-by: Randolph Sapp <rs@ti.com>
WalkthroughThe change refactors the logic for handling empty regex strings in commit checks. The empty regex check and early return are now performed only when the check type is 'message', rather than for all check types. The rest of the control flow and error handling remain unchanged. Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
commit_check/commit.py (1)
42-46
: LGTM! Consider adding defensive checks for robustness.The change correctly moves the empty regex validation inside the message check conditional block, which aligns with the PR objective and maintains consistency with other check types like
check_commit_signoff
.Consider making the regex validation more robust by handling edge cases:
if check['check'] == 'message': - if check['regex'] == "": + if not check.get('regex') or check['regex'].strip() == "": print( f"{YELLOW}Not found regex for commit message. skip checking.{RESET_COLOR}", ) return PASSThis improvement would:
- Handle cases where the 'regex' key might not exist using
get()
- Check for None values and whitespace-only strings
- Maintain backward compatibility with existing behavior
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #260 +/- ##
=======================================
Coverage 99.13% 99.13%
=======================================
Files 8 8
Lines 347 347
=======================================
Hits 344 344
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #260 will not alter performanceComparing Summary
|
This broke with the addition of 2b9711c |
@StaticRocket Thank you so much for the patch! I've released a new version, v0.9.1 commit-check/commit-check-action. Hopefully, it will resolve the failure in your workflow. |
Protect the "regex" key check by first verifying that the check type is "message". Previously check_commit_msg was verifying that all check configuration structures had valid regex keys. This is unnecessary and does not follow the pattern of other checks.
Summary by CodeRabbit