Skip to content

Commit f15423c

Browse files
committed
fix(hook): skip checking merge commits unless strict
1 parent de11cef commit f15423c

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

conventional_pre_commit/hook.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,12 @@ def main(argv=[]):
2424
"--scopes",
2525
type=str,
2626
default=None,
27-
help="Optional list of scopes to support. Scopes should be separated by commas with no spaces (e.g. api,client)",
28-
)
29-
parser.add_argument(
30-
"--skip-merges",
31-
action="store_true",
32-
default=False,
33-
dest="skip_merges",
34-
help="Do not check format for merge commits.",
27+
help="List of scopes to support. Scopes should be separated by commas with no spaces (e.g. api,client).",
3528
)
3629
parser.add_argument(
3730
"--strict",
3831
action="store_true",
39-
help="Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.",
32+
help="Force commit to strictly follow Conventional Commits formatting. Disallows fixup! and merge commits.",
4033
)
4134
parser.add_argument(
4235
"--verbose",
@@ -67,13 +60,11 @@ def main(argv=[]):
6760

6861
commit = ConventionalCommit(commit_msg, args.types, args.optional_scope, scopes)
6962

70-
if args.skip_merges:
71-
if commit.is_merge(commit_msg):
72-
return RESULT_SUCCESS
73-
7463
if not args.strict:
7564
if commit.has_autosquash_prefix():
7665
return RESULT_SUCCESS
66+
if commit.is_merge():
67+
return RESULT_SUCCESS
7768

7869
if commit.is_valid():
7970
return RESULT_SUCCESS

tests/test_hook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ def test_main_fail__fixup_commit(fixup_commit_path):
8585

8686

8787
def test_main_fail__merge_commit(merge_commit_path):
88-
result = main([merge_commit_path])
88+
result = main(["--strict", merge_commit_path])
8989

9090
assert result == RESULT_FAIL
9191

9292

9393
def test_main_success__merge_commit(merge_commit_path):
94-
result = main(["--skip-merges", merge_commit_path])
94+
result = main([merge_commit_path])
9595

9696
assert result == RESULT_SUCCESS
9797

0 commit comments

Comments
 (0)