feat: make author name and email check patterns configurable - #459
Conversation
✅ Deploy Preview for commit-check ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
Next review available in: 19 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds configurable commit author email and name regex patterns through defaults, environment variables, CLI options, and validation rule construction. Updates configuration documentation and ignores Vim swap files. ChangesAuthor pattern validation
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as CLI parser
participant Config as ConfigMerger
participant Rules as RuleBuilder
participant Validation as ValidationRule
CLI->>Config: Provide author email/name patterns
Config->>Rules: Merge commit author configuration
Rules->>Rules: Select author_email or author_name check
Rules->>Validation: Create rule with resolved regex
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
commit_check/main.py (1)
306-318: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor: consider adding
metavarfor consistency.Other
str-typed options in this group (e.g.,--require-rebase-target) set an explicitmetavar(e.g.,BRANCH). Considermetavar="REGEX"here for consistent--helpoutput.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@commit_check/main.py` around lines 306 - 318, The `commit_group.add_argument` definitions for `--author-email-pattern` and `--author-name-pattern` are missing explicit `metavar` values, unlike the other string options in this group. Update both argument declarations in `main.py` to set a consistent `metavar` such as `REGEX` so the `--help` output matches the rest of the CLI options.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@commit_check/config_merger.py`:
- Around line 81-82: The default value for author_name_pattern is currently an
empty string, which disables name validation in the rule builder. Update the
default in the config merger to use the same catalog regex as the built-in
author-name check, and keep the existing author_email_pattern behavior unchanged
so the engine still validates author_name unless an override is explicitly
provided.
In `@commit_check/rule_builder.py`:
- Around line 245-257: The author-name rule builder is currently creating a
ValidationRule with an empty regex when the config value is unset, which makes
AuthorValidator skip the check entirely. Update _build_author_pattern_rule in
rule_builder.py to either return None when the commit config value is empty or
fall back to catalog_entry.regex so the built-in author_name_pattern remains
active. Keep the fix localized to _build_author_pattern_rule and preserve the
existing check/error/suggest fields on ValidationRule.
In `@docs/configuration.rst`:
- Around line 277-282: The configuration table entry for the CLI option is
malformed because the author-email-pattern row has an extra leading backtick,
breaking the inline literal. Update the mapping entry in the configuration table
so the ``--author-email-pattern`` value matches the same double-backtick style
as the neighboring entries, using the affected table row in
docs/configuration.rst as the target.
---
Nitpick comments:
In `@commit_check/main.py`:
- Around line 306-318: The `commit_group.add_argument` definitions for
`--author-email-pattern` and `--author-name-pattern` are missing explicit
`metavar` values, unlike the other string options in this group. Update both
argument declarations in `main.py` to set a consistent `metavar` such as `REGEX`
so the `--help` output matches the rest of the CLI options.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6dc87053-d521-4659-99d1-68b06c1610c9
📒 Files selected for processing (6)
.gitignoreREADME.rstcommit_check/config_merger.pycommit_check/main.pycommit_check/rule_builder.pydocs/configuration.rst
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #459 +/- ##
==========================================
+ Coverage 97.26% 97.28% +0.02%
==========================================
Files 12 12
Lines 1168 1179 +11
==========================================
+ Hits 1136 1147 +11
Misses 32 32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Xianpeng Shen <xianpeng.shen@gmail.com>
678769c to
c53bc92
Compare
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
|
Hi @zerwes, thank you for your PR. Could you please explain a little for your use case why it needs to add Also, could you add appropriate test cases to make sure that the newly added features work as expected? |
Hello @shenxianpeng
Surely. As there are some validation tests for the author name and email defined, I considered additional test as superfluous. Can you be so kind and give me a hint what kind of test you are thinking about? Greetings from Berlin |
|
@zerwes Greetings from Vilnius! 👋 Could you please add the following tests? like:
I'd recommend letting AI generate as comprehensive a test suite as possible, or even let it review the PR and identify any missing test cases or edge cases to make sure everything is well covered. |
Add tests for author_name_pattern / author_email_pattern: custom name and email (company-domain) patterns pass/fail, env-var mapping, and a regression guard that an empty pattern falls back to the built-in regex instead of disabling the check. Replace the Western-name-only example regex in the docs and README with an email-domain example and a permissive full-name example, and correct the author_name_pattern description (empty means built-in default, not disabled).
|
I've rebased it onto main (it needed the |
- Move 4 swallowed test methods back to TestAuthorValidator class - Add metavar='REGEX' to --author-email-pattern and --author-name-pattern - Clarify help text: --author-email/name-pattern requires the check enabled
|
|
Thanks for the fixes and the merge! |



introduces new commit config options
author_name_patternandauthor_email_patternSummary by CodeRabbit
New Features
Documentation
Chores