# Path: pre_commit_hooks/check_merge_conflict.py
# def main(argv: Sequence[str] | None = None) -> int:
#     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() and not args.assume_in_merge:
#         return 0
# 
#     retcode = 0
#     for filename in args.filenames:
#         with open(filename, 'rb') as inputfile:
#             for i, line in enumerate(inputfile):
#                 for pattern in CONFLICT_PATTERNS:
#                     if line.startswith(pattern):
#                         print(
#                             f'Merge conflict string "{pattern.decode()}" '
#                             f'found in {filename}:{i + 1}',
#                         )
#                         retcode = 1
# 
#     return retcode
# 
# Path: pre_commit_hooks/util.py
# def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str:
#     kwargs.setdefault('stdout', subprocess.PIPE)
#     kwargs.setdefault('stderr', subprocess.PIPE)
#     proc = subprocess.Popen(cmd, **kwargs)
#     stdout, stderr = proc.communicate()
#     stdout = stdout.decode()
#     if retcode is not None and proc.returncode != retcode:
#         raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
#     return stdout
# 
# Path: testing/util.py
# def get_resource_path(path):
#     return os.path.join(TESTING_DIR, 'resources', path)
# 
# Path: testing/util.py
# def git_commit(*args, **kwargs):
#     cmd = ('git', 'commit', '--no-gpg-sign', '--no-verify', '--no-edit', *args)
#     subprocess.check_call(cmd, **kwargs)


import os
import shutil
import pytest
from pre_commit_hooks.check_merge_conflict import main
from pre_commit_hooks.util import cmd_output
from testing.util import get_resource_path
from testing.util import git_commit
from __future__ import annotations





@pytest.fixture
def f1_is_a_conflict_file(tmpdir):
    # Make a merge conflict
    repo1 = tmpdir.join('repo1')
    repo1_f1 = repo1.join('f1')
    repo2 = tmpdir.join('repo2')
    repo2_f1 = repo2.join('f1')


# Path: pre_commit_hooks/check_merge_conflict.py
# def main(argv: Sequence[str] | None = None) -> int:
#     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() and not args.assume_in_merge:
#         return 0
# 
#     retcode = 0
#     for filename in args.filenames:
#         with open(filename, 'rb') as inputfile:
#             for i, line in enumerate(inputfile):
#                 for pattern in CONFLICT_PATTERNS:
#                     if line.startswith(pattern):
#                         print(
#                             f'Merge conflict string "{pattern.decode()}" '
#                             f'found in {filename}:{i + 1}',
#                         )
#                         retcode = 1
# 
#     return retcode
# 
# Path: pre_commit_hooks/util.py
# def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str:
#     kwargs.setdefault('stdout', subprocess.PIPE)
#     kwargs.setdefault('stderr', subprocess.PIPE)
#     proc = subprocess.Popen(cmd, **kwargs)
#     stdout, stderr = proc.communicate()
#     stdout = stdout.decode()
#     if retcode is not None and proc.returncode != retcode:
#         raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
#     return stdout
# 
# Path: testing/util.py
# def get_resource_path(path):
#     return os.path.join(TESTING_DIR, 'resources', path)
# 
# Path: testing/util.py
# def git_commit(*args, **kwargs):
#     cmd = ('git', 'commit', '--no-gpg-sign', '--no-verify', '--no-edit', *args)
#     subprocess.check_call(cmd, **kwargs)


# Path: tests/check_merge_conflict_test.py
import os
import shutil
import pytest
from pre_commit_hooks.check_merge_conflict import main
from pre_commit_hooks.util import cmd_output
from testing.util import get_resource_path
from testing.util import git_commit

from __future__ import annotations





@pytest.fixture
def f1_is_a_conflict_file(tmpdir):
    # Make a merge conflict
    repo1 = tmpdir.join('repo1')
    repo1_f1 = repo1.join('f1')
    repo2 = tmpdir.join('repo2')
    repo2_f1 = repo2.join('f1')


    cmd_output('git', 'init', '--', str(repo1))