Skip to content

Commit e32dbbd

Browse files
committed
feat(format): simplify verbose commit ignore regex
1 parent aaa3b7e commit e32dbbd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

conventional_pre_commit/format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def r_autosquash_prefixes():
6969

7070
def r_verbose_commit_ignored():
7171
"""Regex str for verbose diff"""
72-
return r"^# -{24} >8 -{24}\r?\n(?:.*\r?\n)*.*"
72+
return r"^# -{24} >8 -{24}\r?\n.*\Z"
7373

7474

7575
def strip_verbose_commit_ignored(input):
76-
return re.sub(r_verbose_commit_ignored(), "", input, flags=re.MULTILINE)
76+
return re.sub(r_verbose_commit_ignored(), "", input, flags=re.DOTALL | re.MULTILINE)
7777

7878

7979
def r_comment():

tests/test_format.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_strip_comments__spaced():
166166

167167

168168
def test_r_verbose_commit_ignored__does_not_match_no_verbose():
169-
regex = re.compile(format.r_verbose_commit_ignored(), re.MULTILINE)
169+
regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
170170
input = """feat: some commit message
171171
# Please enter the commit message for your changes. Lines starting
172172
# with '#' will be ignored, and an empty message aborts the commit.
@@ -186,7 +186,7 @@ def test_r_verbose_commit_ignored__does_not_match_no_verbose():
186186

187187

188188
def test_r_verbose_commit_ignored__matches_single_verbose_ignored():
189-
regex = re.compile(format.r_verbose_commit_ignored(), re.MULTILINE)
189+
regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
190190
input = """feat: some commit message
191191
# Please enter the commit message for your changes. Lines starting
192192
# with '#' will be ignored, and an empty message aborts the commit.
@@ -218,7 +218,7 @@ def test_r_verbose_commit_ignored__matches_single_verbose_ignored():
218218

219219

220220
def test_r_verbose_commit_ignored__matches_double_verbose_ignored():
221-
regex = re.compile(format.r_verbose_commit_ignored(), re.MULTILINE)
221+
regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
222222
input = """feat: some commit message
223223
# Please enter the commit message for your changes. Lines starting
224224
# with '#' will be ignored, and an empty message aborts the commit.

0 commit comments

Comments
 (0)