feat: attribute a shared path by its declared subject

This commit is contained in:
Abdessamad Derraz committed 2026-08-11 05:42:27 +02:00
1 parent 266567b9a0
commit 3bc9e5ec96
5 files changed
+67 -29

No files matched your search

+18 -1
View File
@@ -575,7 +575,7 @@ HEAD = profile_sync.HEAD
def make_fetch(files: dict[tuple[str, str], list[str]]):
# The real fetch takes the cited line too, so that a path carried by two
# repositories is attributed to the one whose revision is not blank there.
return lambda sha, path, start=None: files.get((sha, path))
return lambda sha, path, start=None, tokens=(): files.get((sha, path))
def renamer(result: CompareResult, head_paths=()):
@@ -1135,6 +1135,23 @@ class TestBuildReport(unittest.TestCase):
self.assertEqual(seen["o/n"], "libretro")
self.assertIsNone(seen["o/up"])
def test_the_subject_beats_a_merely_non_blank_line(self):
# A fork whose tree is offset holds a real but unrelated statement at
# the cited line; the repository carrying the subject wins.
self.files[("portpin", "src/a.cpp")] = ["x", "GAME(1997, drgw2100c", "y"]
self.files[("uppin", "src/a.cpp")] = ["x", "GAME(1997, pgm,", "y"]
self.files[("headsha", "src/a.cpp")] = ["x", "GAME(1997, pgm,", "y"]
profile = {
"emulator": "MAME",
"source": "https://github.com/libretro/mame",
"upstream": "https://github.com/mamedev/mame",
"source_commit": "portpin",
"upstream_commit": "uppin",
"files": [{"name": "pgm.zip", "source_ref": "src/a.cpp:2"}],
}
report = build_report("mame", profile, self.dir)
self.assertEqual(report.entries[0].status, "ANCHORED")
def test_pin_on_the_declared_version_tag_is_flagged(self):
self.files[("pinsha", "a.c")] = ["x", "hit"]
self.files[("headsha", "a.c")] = ["x", "hit"]