Repository: pre-commit/pre-commit-hooks

Issue:
Option to force run check-merge-conflict
check-merge-conflict only runs when it detects merge/rebase in progress.
This means it will always pass on CI setups.

Am not sure if this should be fixed specifically for check-merge-conflict or make a generic CI functionality available via [pre-commit](https://github.com/pre-commit/pre-commit/)


Discussion:

Patch:
diff --git a/pre_commit_hooks/check_merge_conflict.py b/pre_commit_hooks/check_merge_conflict.py
index 5035b6d..6db5efe 100644
--- a/pre_commit_hooks/check_merge_conflict.py
+++ b/pre_commit_hooks/check_merge_conflict.py
@@ -26,9 +26,10 @@ def is_in_merge():
 def detect_merge_conflict(argv=None):
     parser = argparse.ArgumentParser()
     parser.add_argument('filenames', nargs='*')
+    parser.add_argument('--assume-in-merge', action='store_true')
     args = parser.parse_args(argv)
 
-    if not is_in_merge():
+    if not is_in_merge() and not args.assume_in_merge:
         return 0
 
     retcode = 0


Test patch:
diff --git a/tests/check_merge_conflict_test.py b/tests/check_merge_conflict_test.py
index 1045174..b04c70e 100644
--- a/tests/check_merge_conflict_test.py
+++ b/tests/check_merge_conflict_test.py
@@ -128,5 +128,12 @@ def test_ignores_binary_files():
 
 
 def test_does_not_care_when_not_in_a_merge(tmpdir):
-    tmpdir.join('README.md').write('problem\n=======\n')
-    assert detect_merge_conflict(['README.md']) == 0
+    f = tmpdir.join('README.md')
+    f.write_binary(b'problem\n=======\n')
+    assert detect_merge_conflict([str(f.realpath())]) == 0
+
+
+def test_care_when_assumed_merge(tmpdir):
+    f = tmpdir.join('README.md')
+    f.write_binary(b'problem\n=======\n')
+    assert detect_merge_conflict([str(f.realpath()), '--assume-in-merge']) == 1