Skip to content

fix: allow accented letters in author name #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ checks:
suggest: run command `git checkout -b type/branch_name`

- check: author_name
regex: ^[A-Za-z ,.\'-]+$|.*(\[bot])
regex: ^[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017F\u0180-\u024F ,.\'-]+$|.*(\[bot])
error: The committer name seems invalid
suggest: run command `git config user.name "Your Name"`

Expand Down
2 changes: 1 addition & 1 deletion commit_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
'check': 'author_name',
'regex': r'^[A-Za-z ,.\'-]+$|.*(\[bot])',
'regex': r'^[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017F\u0180-\u024F ,.\'-]+$|.*(\[bot])',
'error': 'The committer name seems invalid',
'suggest': 'run command `git config user.name "Your Name"`',
},
Expand Down
20 changes: 20 additions & 0 deletions tests/author_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TestAuthor:
class TestAuthorName:
# used by get_commit_info mock
fake_author_value_an = "fake_author_name"
fake_accented_author_value_an = "fáké_áúthór_námé"

def test_check_author(self, mocker):
# Must call get_commit_info, re.match.
Expand All @@ -29,6 +30,25 @@ def test_check_author(self, mocker):
assert m_get_commit_info.call_count == 1
assert m_re_match.call_count == 1

def test_check_author_with_accented_letters(self, mocker):
# Must call get_commit_info, re.match.
checks = [{
"check": "author_name",
"regex": "dummy_regex"
}]
m_get_commit_info = mocker.patch(
f"{LOCATION}.get_commit_info",
return_value=self.fake_accented_author_value_an
)
m_re_match = mocker.patch(
"re.match",
return_value="fake_rematch_resp"
)
retval = check_author(checks, "author_name")
assert retval == PASS
assert m_get_commit_info.call_count == 1
assert m_re_match.call_count == 1

def test_check_author_with_empty_checks(self, mocker):
# Must NOT call get_commit_info, re.match. with `checks` param with length 0.
checks = []
Expand Down
Loading