Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commit_check/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def _validate_subject(self, subject: str) -> ValidationResult:
# Extract first word (ignore conventional commit prefixes)
import re

match = re.match(r"^(?:\w+(?:\([^)]*\))?[!:]?\s*)?(\w+)", subject)
# support breaking changes (feat!:)
match = re.match(r"^(?:\w+(?:\([^)]*\))?!?:\s*)?(\w+)", subject)
if not match:
return ValidationResult.PASS

Expand Down
20 changes: 20 additions & 0 deletions tests/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,3 +778,23 @@ def test_validate_short_subject(self):
# "add" is a valid imperative word with conventional prefix
result = validator.validate(context)
assert result == ValidationResult.PASS

def test_validate_with_breaking_change(self):
"""Test validation with breaking change notation."""
rule = ValidationRule(check="imperative")
validator = SubjectImperativeValidator(rule)
context = ValidationContext(stdin_text="feat!: update authentication system")

# "update" is a valid imperative word with breaking change notation
result = validator.validate(context)
assert result == ValidationResult.PASS

def test_validate_with_scoped_breaking_change(self):
"""Test validation with scoped breaking change notation."""
rule = ValidationRule(check="imperative")
validator = SubjectImperativeValidator(rule)
context = ValidationContext(stdin_text="fix(auth)!: resolve login bug")

# "resolve" is a valid imperative word with scope and breaking change notation
result = validator.validate(context)
assert result == ValidationResult.PASS
Loading