mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-02 10:56:52 +00:00
Only check merge conflicts on conflict commits
This commit is contained in:
parent
34444ba2c7
commit
635fa7dd9d
3 changed files with 73 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
CONFLICT_PATTERNS = [
|
||||
|
|
@ -11,11 +12,21 @@ CONFLICT_PATTERNS = [
|
|||
WARNING_MSG = 'Merge conflict string "{0}" found in {1}:{2}'
|
||||
|
||||
|
||||
def is_in_merge_conflict():
|
||||
return (
|
||||
os.path.exists(os.path.join('.git', 'MERGE_MSG')) and
|
||||
os.path.exists(os.path.join('.git', 'MERGE_HEAD'))
|
||||
)
|
||||
|
||||
|
||||
def detect_merge_conflict(argv=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*')
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
if not is_in_merge_conflict():
|
||||
return 0
|
||||
|
||||
retcode = 0
|
||||
for filename in args.filenames:
|
||||
with open(filename) as inputfile:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue