Skip to content

Conversation

@shenxianpeng
Copy link
Contributor

@shenxianpeng shenxianpeng commented Oct 12, 2025

closes #301

Summary by CodeRabbit

  • Chores
    • Commit subject validation now recognizes breaking-change notation in conventional commits (e.g., feat!:, fix(scope)!). Expanded prefix handling; behavior for other subjects remains unchanged. No changes to public interfaces or runtime behavior.
  • Tests
    • Added coverage for breaking-change and scoped breaking-change subjects to confirm they are accepted by the validator, improving confidence in commit-check compatibility with common formatting patterns.

@shenxianpeng shenxianpeng requested a review from a team as a code owner October 12, 2025 21:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 12, 2025

Walkthrough

Updated the commit subject validator regex in commit_check/engine.py to support conventional-commit breaking-change syntax (e.g., feat!:, fix(scope)!:). Added two unit tests covering breaking-change cases in tests/engine_test.py. No exported/public API changes.

Changes

Cohort / File(s) Summary
Validator regex update
commit_check/engine.py
Adjusted first-word extraction regex to allow an optional exclamation mark before the colon in conventional-commit prefixes (supports patterns like feat!: and fix(scope)!:). No other logic altered.
Test coverage for breaking changes
tests/engine_test.py
Added tests: test_validate_with_breaking_change and test_validate_with_scoped_breaking_change to validate acceptance of feat!: and fix(scope)!: cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

developer

Poem

I twitch my nose at commits so bright,
Now “feat!:” hops in, a glorious sight.
Regex burrows deeper, snug and tight—
Tests nibble edges, all checks right.
Thump-thump! The log reads clean tonight. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly reflects the primary change by indicating that the regex has been updated to support breaking-change syntax, directly matching the core modification in the commit-check engine without extraneous detail.
Linked Issues Check ✅ Passed The changes directly address issue #301 by extending the SubjectImperativeValidator regex to allow the ! breaking-change marker and adding tests to verify both unscoped and scoped notations, fully satisfying the linked issue’s requirement.
Out of Scope Changes Check ✅ Passed All modifications are confined to updating the regex in engine.py and accompanying tests to support breaking-change syntax, with no unrelated files or logic altered, so no out-of-scope changes are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/fix-301

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 and usage tips.

@github-actions github-actions bot added the bug Something isn't working label Oct 12, 2025
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Oct 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.29%. Comparing base (213b6d2) to head (cd957d9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #305   +/-   ##
=======================================
  Coverage   87.29%   87.29%           
=======================================
  Files           8        8           
  Lines         685      685           
=======================================
  Hits          598      598           
  Misses         87       87           

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

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 12, 2025

CodSpeed Performance Report

Merging #305 will not alter performance

Comparing bugfix/fix-301 (cd957d9) with main (213b6d2)

Summary

✅ 27 untouched
⏩ 85 skipped1

Footnotes

  1. 85 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
tests/engine_test.py (1)

782-800: LGTM! Tests adequately cover breaking change scenarios.

The two new test cases provide good coverage for the breaking change notation feature:

  • Without scope: feat!:
  • With scope: fix(auth)!:

Both tests verify that valid imperative verbs still pass validation with the breaking change marker present.

Consider adding a negative test case to verify that breaking change notation with non-imperative verbs still fails:

def test_validate_with_breaking_change_non_imperative(self):
    """Test validation with breaking change and non-imperative verb."""
    rule = ValidationRule(check="imperative")
    validator = SubjectImperativeValidator(rule)
    context = ValidationContext(stdin_text="feat!: updated authentication system")
    
    with patch("commit_check.util._print_failure"):
        result = validator.validate(context)
        assert result == ValidationResult.FAIL

This would explicitly confirm that the breaking change syntax doesn't bypass imperative mood validation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 213b6d2 and cd957d9.

📒 Files selected for processing (2)
  • commit_check/engine.py (1 hunks)
  • tests/engine_test.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Ensure tests run via pytest -v and cover commit, branch, author, and CLI behaviors

Files:

  • tests/engine_test.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: commit-check/commit-check#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-03T10:28:06.793Z
Learning: Applies to commit_check/commit.py : Support breaking change notation with ! (e.g., feat!: breaking change)
Learnt from: CR
PR: commit-check/commit-check#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-03T10:28:06.793Z
Learning: Applies to commit_check/commit.py : Support optional scope in commits, e.g., feat(api): add endpoint
📚 Learning: 2025-10-03T10:28:06.793Z
Learnt from: CR
PR: commit-check/commit-check#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-03T10:28:06.793Z
Learning: Applies to commit_check/commit.py : Support breaking change notation with ! (e.g., feat!: breaking change)

Applied to files:

  • commit_check/engine.py
🧬 Code graph analysis (1)
tests/engine_test.py (1)
commit_check/engine.py (12)
  • SubjectImperativeValidator (192-213)
  • ValidationContext (27-32)
  • validate (42-44)
  • validate (100-114)
  • validate (137-145)
  • validate (241-250)
  • validate (287-303)
  • validate (309-329)
  • validate (356-370)
  • validate (393-418)
  • validate (441-456)
  • ValidationResult (19-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: install (3.14, ubuntu-24.04)
  • GitHub Check: install (3.13, windows-latest)
  • GitHub Check: install (3.13, ubuntu-24.04)
  • GitHub Check: install (3.13, macos-latest)
  • GitHub Check: install (3.14, macos-latest)
  • GitHub Check: install (3.14, windows-latest)
  • GitHub Check: install (3.11, macos-latest)
  • GitHub Check: install (3.12, ubuntu-24.04)
  • GitHub Check: install (3.9, windows-latest)
  • GitHub Check: install (3.11, windows-latest)
  • GitHub Check: install (3.10, ubuntu-24.04)
  • GitHub Check: install (3.11, ubuntu-24.04)
  • GitHub Check: install (3.12, windows-latest)
  • GitHub Check: install (3.12, macos-latest)
  • GitHub Check: install (3.9, macos-latest)
  • GitHub Check: install (3.9, ubuntu-24.04)
  • GitHub Check: install (3.10, windows-latest)
  • GitHub Check: Run benchmarks
🔇 Additional comments (1)
commit_check/engine.py (1)

203-204: LGTM! Regex correctly supports breaking change notation.

The regex update properly adds support for the conventional commit breaking change indicator (!) while maintaining backward compatibility. The pattern correctly handles:

  • feat!: description
  • fix(scope)!: description
  • All existing formats without !

Based on learnings.

@shenxianpeng shenxianpeng merged commit d0bf5e7 into main Oct 12, 2025
32 checks passed
@shenxianpeng shenxianpeng deleted the bugfix/fix-301 branch October 12, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

commit-check does not support ! (breaking change)

2 participants