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
2 changes: 1 addition & 1 deletion commit_check/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class SignoffValidator(BaseValidator):
"""Validates that commit messages contain required signoff trailer."""

def validate(self, context: ValidationContext) -> ValidationResult:
if self._should_skip_validation(context):
if self._should_skip_commit_validation(context):
return ValidationResult.PASS

message = self._get_commit_message(context)
Expand Down
17 changes: 17 additions & 0 deletions tests/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,23 @@
result = validator.validate(context)
assert result == ValidationResult.FAIL

@patch("commit_check.engine.get_commit_info")
@pytest.mark.benchmark
def test_default_signoff_skips_ignored_author(self, mock_get_commit_info):
"""Signoff check is skipped when the author is in ignore_authors.

A commit with no signoff would normally fail, but an ignored author
(e.g. a bot) should bypass the signoff check just like every other
commit check.
"""
mock_get_commit_info.return_value = "dependabot[bot]"

Check failure on line 720 in tests/engine_test.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "dependabot[bot]" 3 times.

See more on https://sonarcloud.io/project/issues?id=commit-check_commit-check&issues=AZ9Fqy_uhW9_xDpdvUZD&open=AZ9Fqy_uhW9_xDpdvUZD&pullRequest=464
validator = SignoffValidator(self._default_signoff_rule())
config = {"commit": {"ignore_authors": ["dependabot[bot]"]}}
context = ValidationContext(stdin_text="chore: bump dep", config=config)

result = validator.validate(context)
assert result == ValidationResult.PASS

@pytest.mark.benchmark
def test_signoff_validator_missing_signoff(self):
"""Test SignoffValidator with missing signoff."""
Expand Down
Loading