Skip to content

Commit 2a4feaf

Browse files
committed
feat(format): remove strict flag to enforce spec
1 parent 06d5773 commit 2a4feaf

File tree

3 files changed

+14
-38
lines changed

3 files changed

+14
-38
lines changed

conventional_pre_commit/format.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def conventional_types(types=[]):
6161
return types
6262

6363

64-
def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True, is_strict=False):
64+
def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True):
6565
"""
6666
Returns True if input matches Conventional Commits formatting
6767
https://www.conventionalcommits.org
@@ -73,11 +73,11 @@ def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True, is_strict=F
7373
regex = re.compile(pattern, re.MULTILINE)
7474

7575
result = regex.match(input)
76-
is_valid_subject = bool(result)
77-
if is_valid_subject and is_strict and result.group("multi") and not result.group("sep"):
78-
is_valid_subject = False
76+
is_valid = bool(result)
77+
if is_valid and result.group("multi") and not result.group("sep"):
78+
is_valid = False
7979

80-
return is_valid_subject
80+
return is_valid
8181

8282

8383
def has_autosquash_prefix(input):

conventional_pre_commit/hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def main(argv=[]):
5454
if format.has_autosquash_prefix(message):
5555
return RESULT_SUCCESS
5656

57-
if format.is_conventional(message, args.types, args.optional_scope, args.strict):
57+
if format.is_conventional(message, args.types, args.optional_scope):
5858
return RESULT_SUCCESS
5959
else:
6060
print(

tests/test_format.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -162,64 +162,40 @@ def test_is_conventional__with_scope():
162162
assert format.is_conventional(input)
163163

164164

165-
def test_is_conventional__body_multiline_not_strict():
166-
input = """feat(scope): message
167-
168-
more message
169-
"""
170-
171-
assert format.is_conventional(input, is_strict=False)
172-
173-
174-
def test_is_conventional__body_multiline_no_body_not_strict():
175-
input = """feat(scope): message
176-
177-
"""
178-
assert format.is_conventional(input, is_strict=False)
179-
180-
181-
def test_is_conventional__body_multiline_body_bad_type_strict():
165+
def test_is_conventional__body_multiline_body_bad_type():
182166
input = """wrong: message
183167
184168
more_message
185169
"""
186170

187-
assert not format.is_conventional(input, is_strict=True)
188-
189-
190-
def test_is_conventional__bad_body_multiline_not_strict():
191-
input = """feat(scope): message
192-
more message
193-
"""
194-
195-
assert format.is_conventional(input, is_strict=False)
171+
assert not format.is_conventional(input)
196172

197173

198-
def test_is_conventional__bad_body_multiline_strict():
174+
def test_is_conventional__bad_body_multiline():
199175
input = """feat(scope): message
200176
more message
201177
"""
202178

203-
assert not format.is_conventional(input, is_strict=True)
179+
assert not format.is_conventional(input)
204180

205181

206-
def test_is_conventional__body_multiline_strict():
182+
def test_is_conventional__body_multiline():
207183
input = """feat(scope): message
208184
209185
more message
210186
"""
211187

212-
assert format.is_conventional(input, is_strict=True)
188+
assert format.is_conventional(input)
213189

214190

215-
def test_is_conventional__bad_body_multiline_paragraphs_strict():
191+
def test_is_conventional__bad_body_multiline_paragraphs():
216192
input = """feat(scope): message
217193
more message
218194
219195
more body message
220196
"""
221197

222-
assert not format.is_conventional(input, is_strict=True)
198+
assert not format.is_conventional(input)
223199

224200

225201
@pytest.mark.parametrize("char", ['"', "'", "`", "#", "&"])

0 commit comments

Comments
 (0)