conventional-pre-commit 3.3.0__tar.gz → 3.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/PKG-INFO +1 -1
  2. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit/format.py +7 -6
  3. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/PKG-INFO +1 -1
  4. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/run.sh +1 -1
  5. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/test_format.py +253 -49
  6. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.devcontainer/Dockerfile +0 -0
  7. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.devcontainer/compose.yml +0 -0
  8. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.devcontainer/devcontainer.json +0 -0
  9. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.dockerignore +0 -0
  10. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.flake8 +0 -0
  11. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.github/dependabot.yaml +0 -0
  12. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.github/workflows/release.yml +0 -0
  13. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.github/workflows/tests.yml +0 -0
  14. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.gitignore +0 -0
  15. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.pre-commit-config.yaml +0 -0
  16. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.pre-commit-hooks.yaml +0 -0
  17. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/.vscode/settings.json +0 -0
  18. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/LICENSE +0 -0
  19. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/README.md +0 -0
  20. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit/__init__.py +0 -0
  21. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit/hook.py +0 -0
  22. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/SOURCES.txt +0 -0
  23. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/dependency_links.txt +0 -0
  24. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/entry_points.txt +0 -0
  25. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/requires.txt +0 -0
  26. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/conventional_pre_commit.egg-info/top_level.txt +0 -0
  27. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/pyproject.toml +0 -0
  28. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/setup.cfg +0 -0
  29. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/__init__.py +0 -0
  30. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/conftest.py +0 -0
  31. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/bad_commit +0 -0
  32. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit +0 -0
  33. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_bad_multi_line +0 -0
  34. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_gbk +0 -0
  35. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_multi_line +0 -0
  36. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_utf-8 +0 -0
  37. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_with_multiple_scopes +0 -0
  38. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/conventional_commit_with_scope +0 -0
  39. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/custom_commit +0 -0
  40. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/messages/fixup_commit +0 -0
  41. {conventional_pre_commit-3.3.0 → conventional_pre_commit-3.4.0}/tests/test_hook.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: conventional_pre_commit
3
- Version: 3.3.0
3
+ Version: 3.4.0
4
4
  Summary: A pre-commit hook that checks commit messages for Conventional Commits formatting.
5
5
  Author-email: Compiler LLC <dev@compiler.la>
6
6
  License: Apache License
@@ -67,13 +67,14 @@ def r_autosquash_prefixes():
67
67
  return "|".join(AUTOSQUASH_PREFIXES)
68
68
 
69
69
 
70
- def r_verbose_diff():
71
- """Regex str for verbose diff"""
72
- return r"(?P<diff>(^# -* >8 -*$\r?\n)(^# .*$\r?\n)+(diff ){1}(.*\r?\n)*)"
70
+ def r_verbose_commit_ignored():
71
+ """Regex str for the ignored part of verbose commit message templates"""
72
+ return r"^# -{24} >8 -{24}\r?\n.*\Z"
73
73
 
74
74
 
75
- def strip_verbose_diff(input):
76
- return re.sub(r_verbose_diff(), "", input, flags=re.MULTILINE)
75
+ def strip_verbose_commit_ignored(input):
76
+ """Strip the ignored part of verbose commit message templates."""
77
+ return re.sub(r_verbose_commit_ignored(), "", input, flags=re.DOTALL | re.MULTILINE)
77
78
 
78
79
 
79
80
  def r_comment():
@@ -99,7 +100,7 @@ def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True, scopes: Opt
99
100
 
100
101
  Optionally provide a list of additional custom types.
101
102
  """
102
- input = strip_verbose_diff(input)
103
+ input = strip_verbose_commit_ignored(input)
103
104
  input = strip_comments(input)
104
105
  types = conventional_types(types)
105
106
  pattern = f"^({r_types(types)}){r_scope(optional_scope, scopes=scopes)}{r_delim()}{r_subject()}{r_body()}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: conventional_pre_commit
3
- Version: 3.3.0
3
+ Version: 3.4.0
4
4
  Summary: A pre-commit hook that checks commit messages for Conventional Commits formatting.
5
5
  Author-email: Compiler LLC <dev@compiler.la>
6
6
  License: Apache License
@@ -7,5 +7,5 @@ coverage run -m pytest
7
7
  # clean out old coverage results
8
8
  rm -rf ./tests/coverage
9
9
 
10
- # regenerate coverate report
10
+ # regenerate coverage report
11
11
  coverage html --directory ./tests/coverage
@@ -165,71 +165,275 @@ def test_strip_comments__spaced():
165
165
  assert result.strip() == "feat(scope): message"
166
166
 
167
167
 
168
- def test_r_verbose_diff__has_diff():
169
- regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
170
- input = """# ----------- >8 -----------
171
- # Some comment
172
- # Some comment
173
- diff --git a/file b/file
168
+ def test_r_verbose_commit_ignored__does_not_match_no_verbose():
169
+ regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
170
+ input = """feat: some commit message
171
+ # Please enter the commit message for your changes. Lines starting
172
+ # with '#' will be ignored, and an empty message aborts the commit.
173
+ #
174
+ # On branch main
175
+ # Your branch is up to date with 'origin/main'.
176
+ #
177
+ # Changes to be committed:
178
+ # modified: README.md
179
+ #
180
+ # Changes not staged for commit:
181
+ # modified: README.md
182
+ #
174
183
  """
175
184
 
176
- assert regex.match(input)
177
-
178
-
179
- def test_r_verbose_diff__no_diff():
180
- regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
181
- input = """# ----------- >8 -----------
182
- # Some comment
183
- # Some comment
185
+ assert not regex.search(input)
186
+
187
+
188
+ def test_r_verbose_commit_ignored__matches_single_verbose_ignored():
189
+ regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
190
+ input = (
191
+ """feat: some commit message
192
+ # Please enter the commit message for your changes. Lines starting
193
+ # with '#' will be ignored, and an empty message aborts the commit.
194
+ #
195
+ # On branch main
196
+ # Your branch is up to date with 'origin/main'.
197
+ #
198
+ # Changes to be committed:
199
+ # modified: README.md
200
+ #
201
+ # Changes not staged for commit:
202
+ # modified: README.md
203
+ #
204
+ # ------------------------ >8 ------------------------
205
+ # Do not modify or remove the line above.
206
+ # Everything below it will be ignored.
207
+ diff --git c/README.md i/README.md
208
+ index ea80a93..fe8a527 100644
209
+ --- c/README.md
210
+ +++ i/README.md
211
+ @@ -20,3 +20,4 @@ Some hunk header
212
+ Context 1
184
213
  """
185
-
186
- assert not regex.match(input)
187
-
188
-
189
- def test_r_verbose_diff__no_extra_comments():
190
- regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
191
- input = """# ----------- >8 -----------
192
- diff --git a/file b/file
214
+ + " " # This is on purpose to preserve the space from overly eager stripping.
215
+ + """
216
+ Context 2
217
+ +Added line
193
218
  """
219
+ )
194
220
 
195
- assert not regex.match(input)
196
-
197
-
198
- def test_strip_verbose_diff__has_diff():
199
- input = """feat(scope): message
200
- # Please enter the commit message for your changes.
221
+ assert regex.search(input)
222
+
223
+
224
+ def test_r_verbose_commit_ignored__matches_double_verbose_ignored():
225
+ regex = re.compile(format.r_verbose_commit_ignored(), re.DOTALL | re.MULTILINE)
226
+ input = (
227
+ """feat: some commit message
228
+ # Please enter the commit message for your changes. Lines starting
229
+ # with '#' will be ignored, and an empty message aborts the commit.
230
+ #
231
+ # On branch main
232
+ # Your branch is up to date with 'origin/main'.
233
+ #
234
+ # Changes to be committed:
235
+ # modified: README.md
236
+ #
237
+ # Changes not staged for commit:
238
+ # modified: README.md
239
+ #
240
+ # ------------------------ >8 ------------------------
241
+ # Do not modify or remove the line above.
242
+ # Everything below it will be ignored.
243
+ #
244
+ # Changes to be committed:
245
+ diff --git c/README.md i/README.md
246
+ index ea80a93..fe8a527 100644
247
+ --- c/README.md
248
+ +++ i/README.md
249
+ @@ -20,3 +20,4 @@ Some staged hunk header
250
+ Staged Context 1
251
+ """
252
+ + " " # This is on purpose to preserve the space from overly eager stripping.
253
+ + """
254
+ Staged Context 2
255
+ +Staged added line
256
+ # --------------------------------------------------
257
+ # Changes not staged for commit:
258
+ diff --git i/README.md w/README.md
259
+ index fe8a527..1c00c14 100644
260
+ --- i/README.md
261
+ +++ w/README.md
262
+ @@ -10,6 +10,7 @@ Some unstaged hunk header
263
+ Context 1
264
+ Context 2
265
+ Context 3
266
+ -Removed line
267
+ +Added line
268
+ """
269
+ + " " # This is on purpose to preserve the space from overly eager stripping.
270
+ + """
271
+ Context 4
272
+ """
273
+ + " " # This is on purpose to preserve the space from overly eager stripping.
274
+ + """
275
+ """
276
+ )
201
277
 
202
- # These are comments usually added by editors, f.ex. with export EDITOR=vim
203
- # ----------- >8 -----------
204
- # Some comment
205
- # Some comment
206
- diff --git a/file b/file
278
+ assert regex.search(input)
279
+
280
+
281
+ def test_strip_verbose_commit_ignored__does_not_strip_no_verbose():
282
+ input = """feat: some commit message
283
+ # Please enter the commit message for your changes. Lines starting
284
+ # with '#' will be ignored, and an empty message aborts the commit.
285
+ #
286
+ # On branch main
287
+ # Your branch is up to date with 'origin/main'.
288
+ #
289
+ # Changes to be committed:
290
+ # modified: README.md
291
+ #
292
+ # Changes not staged for commit:
293
+ # modified: README.md
294
+ #
207
295
  """
208
296
 
209
- result = format.strip_verbose_diff(input)
210
- assert result.count("\n") == 4
211
- assert (
212
- result
213
- == """feat(scope): message
214
- # Please enter the commit message for your changes.
297
+ expected = """feat: some commit message
298
+ # Please enter the commit message for your changes. Lines starting
299
+ # with '#' will be ignored, and an empty message aborts the commit.
300
+ #
301
+ # On branch main
302
+ # Your branch is up to date with 'origin/main'.
303
+ #
304
+ # Changes to be committed:
305
+ # modified: README.md
306
+ #
307
+ # Changes not staged for commit:
308
+ # modified: README.md
309
+ #
310
+ """
215
311
 
216
- # These are comments usually added by editors, f.ex. with export EDITOR=vim
312
+ result = format.strip_verbose_commit_ignored(input)
313
+ assert result == expected
314
+
315
+
316
+ def test_strip_verbose_commit_ignored__strips_single_verbose_ignored():
317
+ input = (
318
+ """feat: some commit message
319
+ # Please enter the commit message for your changes. Lines starting
320
+ # with '#' will be ignored, and an empty message aborts the commit.
321
+ #
322
+ # On branch main
323
+ # Your branch is up to date with 'origin/main'.
324
+ #
325
+ # Changes to be committed:
326
+ # modified: README.md
327
+ #
328
+ # Changes not staged for commit:
329
+ # modified: README.md
330
+ #
331
+ # ------------------------ >8 ------------------------
332
+ # Do not modify or remove the line above.
333
+ # Everything below it will be ignored.
334
+ diff --git c/README.md i/README.md
335
+ index ea80a93..fe8a527 100644
336
+ --- c/README.md
337
+ +++ i/README.md
338
+ @@ -20,3 +20,4 @@ Some hunk header
339
+ Context 1
340
+ """
341
+ + " " # This is on purpose to preserve the space from overly eager stripping.
342
+ + """
343
+ Context 2
344
+ +Added line
217
345
  """
218
346
  )
219
347
 
348
+ expected = """feat: some commit message
349
+ # Please enter the commit message for your changes. Lines starting
350
+ # with '#' will be ignored, and an empty message aborts the commit.
351
+ #
352
+ # On branch main
353
+ # Your branch is up to date with 'origin/main'.
354
+ #
355
+ # Changes to be committed:
356
+ # modified: README.md
357
+ #
358
+ # Changes not staged for commit:
359
+ # modified: README.md
360
+ #
361
+ """
220
362
 
221
- def test_strip_verbose_diff__no_diff():
222
- input = """feat(scope): message
223
- # Please enter the commit message for your changes.
363
+ result = format.strip_verbose_commit_ignored(input)
364
+ assert result == expected
365
+
366
+
367
+ def test_strip_verbose_commit_ignored__strips_double_verbose_ignored():
368
+ input = (
369
+ """feat: some commit message
370
+ # Please enter the commit message for your changes. Lines starting
371
+ # with '#' will be ignored, and an empty message aborts the commit.
372
+ #
373
+ # On branch main
374
+ # Your branch is up to date with 'origin/main'.
375
+ #
376
+ # Changes to be committed:
377
+ # modified: README.md
378
+ #
379
+ # Changes not staged for commit:
380
+ # modified: README.md
381
+ #
382
+ # ------------------------ >8 ------------------------
383
+ # Do not modify or remove the line above.
384
+ # Everything below it will be ignored.
385
+ #
386
+ # Changes to be committed:
387
+ diff --git c/README.md i/README.md
388
+ index ea80a93..fe8a527 100644
389
+ --- c/README.md
390
+ +++ i/README.md
391
+ @@ -20,3 +20,4 @@ Some staged hunk header
392
+ Staged Context 1
393
+ """
394
+ + " " # This is on purpose to preserve the space from overly eager stripping.
395
+ + """
396
+ Staged Context 2
397
+ +Staged added line
398
+ # --------------------------------------------------
399
+ # Changes not staged for commit:
400
+ diff --git i/README.md w/README.md
401
+ index fe8a527..1c00c14 100644
402
+ --- i/README.md
403
+ +++ w/README.md
404
+ @@ -10,6 +10,7 @@ Some unstaged hunk header
405
+ Context 1
406
+ Context 2
407
+ Context 3
408
+ -Removed line
409
+ +Added line
410
+ """
411
+ + " " # This is on purpose to preserve the space from overly eager stripping.
412
+ + """
413
+ Context 4
414
+ """
415
+ + " " # This is on purpose to preserve the space from overly eager stripping.
416
+ + """
417
+ """
418
+ )
224
419
 
225
- # These are comments usually added by editors, f.ex. with export EDITOR=vim
226
- # ----------- >8 -----------
227
- # Some comment
228
- # Some comment
420
+ expected = """feat: some commit message
421
+ # Please enter the commit message for your changes. Lines starting
422
+ # with '#' will be ignored, and an empty message aborts the commit.
423
+ #
424
+ # On branch main
425
+ # Your branch is up to date with 'origin/main'.
426
+ #
427
+ # Changes to be committed:
428
+ # modified: README.md
429
+ #
430
+ # Changes not staged for commit:
431
+ # modified: README.md
432
+ #
229
433
  """
230
434
 
231
- result = format.strip_verbose_diff(input)
232
- assert result == input
435
+ result = format.strip_verbose_commit_ignored(input)
436
+ assert result == expected
233
437
 
234
438
 
235
439
  @pytest.mark.parametrize("type", format.DEFAULT_TYPES)