fix(tools): use the shared merge base for overlap checks

This commit is contained in:
MarcZX100 2026-10-13 06:01:10 +00:00
parent 2a91815210
commit c7aca86c61
2 changed files with 10 additions and 1 deletions

View File

@ -139,7 +139,7 @@ def clashes(a, b, path):
def conflicts(a, b):
if not (a["tree"] and b["tree"] and a["files"] & b["files"]):
return {}
files = merge("--merge-base=refs/pr/base", a["tree"], b["tree"])[1]
files = merge(a["tree"], b["tree"])[1]
return {path: [] if path in a["added"] else clashes(a, b, path) for path in files}

View File

@ -108,5 +108,14 @@ class FetchTests(unittest.TestCase):
self.assertEqual(git.call_args_list[-1].args[-1], "+00000000000000000000000000000000000000f9:refs/pr/249")
class ConflictTests(unittest.TestCase):
def test_uses_the_shared_base_parent_without_newer_merge_tree_option(self):
first = {"tree": "first-tree", "files": {"shared.cpp"}, "added": set()}
second = {"tree": "second-tree", "files": {"shared.cpp"}, "added": set()}
with patch.object(pr_overlap, "merge", return_value=("merged-tree", set())) as merge:
self.assertEqual(pr_overlap.conflicts(first, second), {})
merge.assert_called_once_with("first-tree", "second-tree")
if __name__ == "__main__":
unittest.main()