Skip to content

Commit 28dbfe5

Browse files
committed
feat(test): protect verbose commit message spaces
These were stripped by overly eager trailing whitespace stripping.
1 parent e32dbbd commit 28dbfe5

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

tests/test_format.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ def test_r_verbose_commit_ignored__does_not_match_no_verbose():
187187

188188
def test_r_verbose_commit_ignored__matches_single_verbose_ignored():
189189
regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
190-
input = """feat: some commit message
190+
input = (
191+
"""feat: some commit message
191192
# Please enter the commit message for your changes. Lines starting
192193
# with '#' will be ignored, and an empty message aborts the commit.
193194
#
@@ -209,17 +210,21 @@ def test_r_verbose_commit_ignored__matches_single_verbose_ignored():
209210
+++ i/README.md
210211
@@ -20,3 +20,4 @@ Some hunk header
211212
Context 1
212-
213+
"""
214+
+ " " # This is on purpose to preserve the space from overly eager stripping.
215+
+ """
213216
Context 2
214217
+Added line
215218
"""
219+
)
216220

217221
assert regex.search(input)
218222

219223

220224
def test_r_verbose_commit_ignored__matches_double_verbose_ignored():
221225
regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
222-
input = """feat: some commit message
226+
input = (
227+
"""feat: some commit message
223228
# Please enter the commit message for your changes. Lines starting
224229
# with '#' will be ignored, and an empty message aborts the commit.
225230
#
@@ -243,7 +248,9 @@ def test_r_verbose_commit_ignored__matches_double_verbose_ignored():
243248
+++ i/README.md
244249
@@ -20,3 +20,4 @@ Some staged hunk header
245250
Staged Context 1
246-
251+
"""
252+
+ " " # This is on purpose to preserve the space from overly eager stripping.
253+
+ """
247254
Staged Context 2
248255
+Staged added line
249256
# --------------------------------------------------
@@ -258,10 +265,15 @@ def test_r_verbose_commit_ignored__matches_double_verbose_ignored():
258265
Context 3
259266
-Removed line
260267
+Added line
261-
268+
"""
269+
+ " " # This is on purpose to preserve the space from overly eager stripping.
270+
+ """
262271
Context 4
263-
264272
"""
273+
+ " " # This is on purpose to preserve the space from overly eager stripping.
274+
+ """
275+
"""
276+
)
265277

266278
assert regex.search(input)
267279

@@ -302,7 +314,8 @@ def test_strip_verbose_commit_ignored__does_not_strip_no_verbose():
302314

303315

304316
def test_strip_verbose_commit_ignored__strips_single_verbose_ignored():
305-
input = """feat: some commit message
317+
input = (
318+
"""feat: some commit message
306319
# Please enter the commit message for your changes. Lines starting
307320
# with '#' will be ignored, and an empty message aborts the commit.
308321
#
@@ -324,10 +337,13 @@ def test_strip_verbose_commit_ignored__strips_single_verbose_ignored():
324337
+++ i/README.md
325338
@@ -20,3 +20,4 @@ Some hunk header
326339
Context 1
327-
340+
"""
341+
+ " " # This is on purpose to preserve the space from overly eager stripping.
342+
+ """
328343
Context 2
329344
+Added line
330345
"""
346+
)
331347

332348
expected = """feat: some commit message
333349
# Please enter the commit message for your changes. Lines starting
@@ -349,7 +365,8 @@ def test_strip_verbose_commit_ignored__strips_single_verbose_ignored():
349365

350366

351367
def test_strip_verbose_commit_ignored__strips_double_verbose_ignored():
352-
input = """feat: some commit message
368+
input = (
369+
"""feat: some commit message
353370
# Please enter the commit message for your changes. Lines starting
354371
# with '#' will be ignored, and an empty message aborts the commit.
355372
#
@@ -373,7 +390,9 @@ def test_strip_verbose_commit_ignored__strips_double_verbose_ignored():
373390
+++ i/README.md
374391
@@ -20,3 +20,4 @@ Some staged hunk header
375392
Staged Context 1
376-
393+
"""
394+
+ " " # This is on purpose to preserve the space from overly eager stripping.
395+
+ """
377396
Staged Context 2
378397
+Staged added line
379398
# --------------------------------------------------
@@ -388,10 +407,15 @@ def test_strip_verbose_commit_ignored__strips_double_verbose_ignored():
388407
Context 3
389408
-Removed line
390409
+Added line
391-
410+
"""
411+
+ " " # This is on purpose to preserve the space from overly eager stripping.
412+
+ """
392413
Context 4
393-
394414
"""
415+
+ " " # This is on purpose to preserve the space from overly eager stripping.
416+
+ """
417+
"""
418+
)
395419

396420
expected = """feat: some commit message
397421
# Please enter the commit message for your changes. Lines starting

0 commit comments

Comments
 (0)