mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix merge conflict detection for cherry-pick conflict.
This commit is contained in:
parent
5a1accd697
commit
c4e4c2dccb
2 changed files with 13 additions and 3 deletions
|
|
@ -23,7 +23,10 @@ def get_root():
|
||||||
|
|
||||||
|
|
||||||
def is_in_merge_conflict():
|
def is_in_merge_conflict():
|
||||||
return os.path.exists(os.path.join('.git', 'MERGE_MSG'))
|
return (
|
||||||
|
os.path.exists(os.path.join('.git', 'MERGE_MSG')) and
|
||||||
|
os.path.exists(os.path.join('.git', 'MERGE_HEAD'))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_merge_msg_for_conflicts(merge_msg):
|
def parse_merge_msg_for_conflicts(merge_msg):
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,21 @@ def test_get_root(empty_git_dir):
|
||||||
assert git.get_root() == empty_git_dir
|
assert git.get_root() == empty_git_dir
|
||||||
|
|
||||||
|
|
||||||
def test_is_in_merge_conflict(empty_git_dir):
|
def test_is_not_in_merge_conflict(empty_git_dir):
|
||||||
assert git.is_in_merge_conflict() is False
|
assert git.is_in_merge_conflict() is False
|
||||||
|
|
||||||
|
|
||||||
def test_is_not_in_merge_conflict(in_merge_conflict):
|
def test_is_in_merge_conflict(in_merge_conflict):
|
||||||
assert git.is_in_merge_conflict() is True
|
assert git.is_in_merge_conflict() is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_cherry_pick_conflict(in_merge_conflict):
|
||||||
|
local['git']('merge', '--abort')
|
||||||
|
foo_ref = local['git']('rev-parse', 'foo').strip()
|
||||||
|
local['git']('cherry-pick', foo_ref, retcode=None)
|
||||||
|
assert git.is_in_merge_conflict() is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def get_files_matching_func():
|
def get_files_matching_func():
|
||||||
def get_filenames():
|
def get_filenames():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue