Skip to content

Commit a237cda

Browse files
fix: allow accented letters in author name (#221)
* fix: allow accented letters in author name Allow accented letters (e.g. áéó, etc.) in an author's name. * fix: remove duplicate unicode regex range * fix: add broader regex range to .yml as well * fix: remove duplicate regex key
1 parent 41e0244 commit a237cda

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.commit-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ checks:
1414
suggest: run command `git checkout -b type/branch_name`
1515

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

commit_check/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
'check': 'author_name',
35-
'regex': r'^[A-Za-z ,.\'-]+$|.*(\[bot])',
35+
'regex': r'^[A-Za-zÀ-ÖØ-öø-ÿ\u0100-\u017F\u0180-\u024F ,.\'-]+$|.*(\[bot])',
3636
'error': 'The committer name seems invalid',
3737
'suggest': 'run command `git config user.name "Your Name"`',
3838
},

tests/author_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class TestAuthor:
99
class TestAuthorName:
1010
# used by get_commit_info mock
1111
fake_author_value_an = "fake_author_name"
12+
fake_accented_author_value_an = "fáké_áúthór_námé"
1213

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

33+
def test_check_author_with_accented_letters(self, mocker):
34+
# Must call get_commit_info, re.match.
35+
checks = [{
36+
"check": "author_name",
37+
"regex": "dummy_regex"
38+
}]
39+
m_get_commit_info = mocker.patch(
40+
f"{LOCATION}.get_commit_info",
41+
return_value=self.fake_accented_author_value_an
42+
)
43+
m_re_match = mocker.patch(
44+
"re.match",
45+
return_value="fake_rematch_resp"
46+
)
47+
retval = check_author(checks, "author_name")
48+
assert retval == PASS
49+
assert m_get_commit_info.call_count == 1
50+
assert m_re_match.call_count == 1
51+
3252
def test_check_author_with_empty_checks(self, mocker):
3353
# Must NOT call get_commit_info, re.match. with `checks` param with length 0.
3454
checks = []

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy