feat: make author name and email check patterns configurable#459
feat: make author name and email check patterns configurable#459zerwes wants to merge 5 commits into
Conversation
✅ Deploy Preview for commit-check ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds commit author email/name pattern configuration, CLI flags, and rule-building support, then documents the new options in the README and configuration guide. Also adds ChangesAuthor Pattern Validation Feature
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant CLIParser
participant ConfigMerger
participant RuleBuilder
participant ValidationRule
CLIParser->>ConfigMerger: author pattern option values
ConfigMerger->>RuleBuilder: commit author pattern settings
RuleBuilder->>RuleBuilder: select author check and resolve regex
RuleBuilder->>ValidationRule: construct validation rule
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.42% 97.27% -0.15%
==========================================
Files 12 12
Lines 1163 1174 +11
==========================================
+ Hits 1133 1142 +9
- Misses 30 32 +2 ☔ 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
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. |
|



introduces new commit config options
author_name_patternandauthor_email_patternSummary by CodeRabbit
*.swp).