Skip to content

Commit 10d1e31

Browse files
committed
fix: scope now allows usage of dots
1 parent 37b5f04 commit 10d1e31

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

conventional_pre_commit/format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def r_scope(self):
128128
"""Regex str for an optional (scope)."""
129129
if self.scopes:
130130
scopes = self._r_or(self.scopes)
131-
escaped_delimiters = list(map(re.escape, [":", ",", "-", "/"])) # type: ignore
131+
escaped_delimiters = list(map(re.escape, [":", ",", "-", "/", "."])) # type: ignore
132132
delimiters_pattern = self._r_or(escaped_delimiters)
133133
scope_pattern = rf"\(\s*(?:(?i:{scopes}))(?:\s*(?:{delimiters_pattern})\s*(?:(?i:{scopes})))*\s*\)"
134134

@@ -138,9 +138,9 @@ def r_scope(self):
138138
return scope_pattern
139139

140140
if self.scope_optional:
141-
return r"(\([\w \/:,-]+\))?"
141+
return r"(\([\w \/:,-\.]+\))?"
142142
else:
143-
return r"(\([\w \/:,-]+\))"
143+
return r"(\([\w \/:,-\.]+\))"
144144

145145
@property
146146
def r_delim(self):

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def conventional_utf8_commit_path():
3434
return get_message_path("conventional_commit_utf-8")
3535

3636

37+
@pytest.fixture
38+
def conventional_commit_with_dots_path():
39+
return get_message_path("conventional_commit_with_dots")
40+
41+
3742
@pytest.fixture
3843
def conventional_gbk_commit_path():
3944
return get_message_path("conventional_commit_gbk")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat(customer.registration): adds support for oauth2

tests/test_format.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ def test_r_scope__special_chars(conventional_commit_scope_required):
443443
assert regex.match("(some thing)")
444444
assert regex.match("(some:thing)")
445445
assert regex.match("(some,thing)")
446+
assert regex.match("(some.thing)")
446447

447448

448449
def test_r_scope__scopes(conventional_commit_scope_required):
@@ -455,6 +456,7 @@ def test_r_scope__scopes(conventional_commit_scope_required):
455456
assert regex.match("(api: client)")
456457
assert regex.match("(api/client)")
457458
assert regex.match("(api-client)")
459+
assert regex.match("(api.client)")
458460
assert not regex.match("(test)")
459461
assert not regex.match("(api; client)")
460462

@@ -469,6 +471,7 @@ def test_r_scope__scopes_uppercase(conventional_commit_scope_required):
469471
assert regex.match("(API: CLIENT)")
470472
assert regex.match("(API/CLIENT)")
471473
assert regex.match("(API-CLIENT)")
474+
assert regex.match("(API.CLIENT)")
472475
assert not regex.match("(TEST)")
473476
assert not regex.match("(API; CLIENT)")
474477

tests/test_hook.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ def test_main_success__conventional_utf8(conventional_utf8_commit_path):
5454
assert result == RESULT_SUCCESS
5555

5656

57+
def test_main_success__conventional_commit_with_dots_path(conventional_commit_with_dots_path):
58+
result = main([conventional_commit_with_dots_path])
59+
60+
assert result == RESULT_SUCCESS
61+
62+
5763
def test_main_fail__conventional_gbk(conventional_gbk_commit_path):
5864
result = main([conventional_gbk_commit_path])
5965

0 commit comments

Comments
 (0)