Skip to content

feat: make author name and email check patterns configurable#459

Open
zerwes wants to merge 5 commits into
commit-check:mainfrom
zerwes:feature/author_checks_configurable_pattern
Open

feat: make author name and email check patterns configurable#459
zerwes wants to merge 5 commits into
commit-check:mainfrom
zerwes:feature/author_checks_configurable_pattern

Conversation

@zerwes

@zerwes zerwes commented Jul 6, 2026

Copy link
Copy Markdown

introduces new commit config options author_name_pattern and author_email_pattern

Summary by CodeRabbit

  • New Features
    • Added pattern-based validation for commit author email and author name.
    • Introduced new author pattern configuration options, along with matching CLI flags and environment variables.
  • Documentation
    • Documented the new author pattern options in the configuration reference, including their defaults and mappings.
    • Updated the pre-commit hook example to include the new author-name validation hook settings.
  • Chores
    • Updated ignore rules to exclude Vim swap files (*.swp).

@zerwes
zerwes requested a review from a team as a code owner July 6, 2026 16:55
@zerwes
zerwes requested review from shenxianpeng and removed request for a team July 6, 2026 16:55
@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit c784cbd
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/6a5745ce338095000895647a
😎 Deploy Preview https://deploy-preview-459--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b42e92e2-2b9b-422a-b659-d6c6588cbb20

📥 Commits

Reviewing files that changed from the base of the PR and between 9b3cfef and c784cbd.

📒 Files selected for processing (3)
  • README.rst
  • commit_check/main.py
  • docs/configuration.rst
💤 Files with no reviewable changes (1)
  • commit_check/main.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/configuration.rst

📝 Walkthrough

Walkthrough

Adds 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 *.swp to .gitignore.

Changes

Author Pattern Validation Feature

Layer / File(s) Summary
Author pattern configuration and CLI wiring
commit_check/config_merger.py, commit_check/main.py
Adds author pattern defaults, environment-variable and CLI mappings, and the corresponding command-line options.
Rule builder support for author patterns
commit_check/rule_builder.py
Adds author_email and author_name handling and builds validation rules from configured or catalog regex patterns.
Documentation and pre-commit example updates
docs/configuration.rst, README.rst
Documents the new options and adds a check-author-name pre-commit example.
Vim swap-file ignore update
.gitignore
Ignores Vim swap files with *.swp.

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
Loading

Suggested labels: documentation

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: configurable author name and email check patterns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
commit_check/main.py (1)

306-318: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor: consider adding metavar for consistency.

Other str-typed options in this group (e.g., --require-rebase-target) set an explicit metavar (e.g., BRANCH). Consider metavar="REGEX" here for consistent --help output.

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9e26b4f and f7c685a.

📒 Files selected for processing (6)
  • .gitignore
  • README.rst
  • commit_check/config_merger.py
  • commit_check/main.py
  • commit_check/rule_builder.py
  • docs/configuration.rst

Comment thread commit_check/config_merger.py
Comment thread commit_check/rule_builder.py
Comment thread docs/configuration.rst
@shenxianpeng shenxianpeng changed the title feature: make the author check patterns configurable feat: make author name and email check patterns configurable Jul 6, 2026
Comment thread README.rst Outdated
Comment thread README.rst Outdated
Comment thread README.rst Outdated
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.27%. Comparing base (af03234) to head (c784cbd).
⚠️ Report is 5 commits behind head on main.

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.
📢 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.

@shenxianpeng
shenxianpeng force-pushed the feature/author_checks_configurable_pattern branch from 678769c to c53bc92 Compare July 6, 2026 18:20
@codspeed-hq

codspeed-hq Bot commented Jul 6, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 362 untouched benchmarks
⏩ 114 skipped benchmarks1


Comparing zerwes:feature/author_checks_configurable_pattern (c784cbd) with main (af03234)

Open in CodSpeed

Footnotes

  1. 114 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@shenxianpeng

shenxianpeng commented Jul 6, 2026

Copy link
Copy Markdown
Member

Hi @zerwes, thank you for your PR. Could you please explain a little for your use case why it needs to add author_name_pattern and author_email_pattern? (I'm not opposed to adding this feature, but I'd just like to hear about some use cases)

Also, could you add appropriate test cases to make sure that the newly added features work as expected?

@shenxianpeng shenxianpeng added enhancement New feature or request minor A minor version bump labels Jul 6, 2026
@zerwes

zerwes commented Jul 6, 2026

Copy link
Copy Markdown
Author

Hi @zerwes, thank you for your PR. Could you please explain a little for your use case why it needs to add author_name_pattern and author_email_pattern? (I'm not opposed to adding this feature, but I'd just like to hear about some use cases)

Hello @shenxianpeng
My intention is to have some restricted validation regarding author email and author name as a pre-commit check. We use pre-commit for a wide variety of tests. And as the request for the author name and email validation was made, I came around your commit-check, and realized it meets my requirements, but just was missing the configurable patterns.

Also, could you add appropriate test cases to make sure that the newly added features work as expected?

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

@shenxianpeng

Copy link
Copy Markdown
Member

@zerwes Greetings from Vilnius! 👋

Could you please add the following tests? like:

  1. Tests for author_email_pattern (pass/fail cases, Config/CLI/Env support).
  2. Tests for author_name_pattern (pass/fail cases, Config/CLI/Env support).
  3. Maybe regression tests to ensure the default author-name validation still works when no custom pattern is configured.
  4. Maybe precedence tests verifying CLI/Environment Variable overrides TOML configuration.

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.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor A minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants