Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for diff3-style merge conflict artifacts. #586

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pre_commit_hooks/check_merge_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
b'<<<<<<< ',
b'======= ',
b'=======\n',
b'||||||| ',
b'|||||||\n',
b'>>>>>>> ',
]

Expand Down
24 changes: 24 additions & 0 deletions tests/check_merge_conflict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,32 @@ def test_does_not_care_when_not_in_a_merge(tmpdir):
f.write_binary(b'problem\n=======\n')
assert main([str(f.realpath())]) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n======= \n')
assert main([str(f.realpath())]) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n|||||||\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 0

f = tmpdir.join('README.md')
f.write_binary(b'problem\n||||||| \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 0


def test_care_when_assumed_merge(tmpdir):
f = tmpdir.join('README.md')
f.write_binary(b'problem\n=======\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n======= \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n|||||||\n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1

f = tmpdir.join('README.md')
f.write_binary(b'problem\n||||||| \n')
assert main([str(f.realpath()), '--assume-in-merge']) == 1