feat: name the file each platform page transcribes

This commit is contained in:
Abdessamad Derraz committed 2026-10-19 04:35:08 +02:00
1 parent 2abef61acd
commit 49e7119b1c
2 files changed
+29

No files matched your search

+9
View File
@@ -1840,6 +1840,15 @@ def generate_platform_page(
lines.append(f"| BIOS path | `{base_dest}/` |")
if homepage:
lines.append(f"| Homepage | [{homepage}]({homepage}) |")
transcribed = str(config.get("source") or "")
if transcribed:
# The file every declaration on this page was read from: without it
# a hash could not be traced to the revision that states it.
moving = re.search(r"/(?:master|main|db)(?:/|$)|refs/heads/", transcribed) or (
re.fullmatch(r"https://(?:github|gitlab)\.com/[^/]+/[^/]+/?", transcribed)
)
note = " (a branch: the revision read is not recorded)" if moving else ""
lines.append(f"| Transcribed from | <{transcribed}>{note} |")
contrib_list = (registry or {}).get(name, {}).get("contributed_by", [])
if contrib_list:
for cb in contrib_list:
+20
View File
@@ -607,5 +607,25 @@ class ADataDirectorySaysWhatItIs(unittest.TestCase):
self.assertIn("src/main.cpp#L10", page)
class APlatformPageNamesTheFileItTranscribes(unittest.TestCase):
"""Batocera's page gave 'Version 43.1' and a homepage, never the
batocera-systems revision every md5 on it comes from."""
def test_pinned_and_moving_sources(self):
import generate_site # noqa: PLC0415
def page(source: str) -> str:
cov = {"platform": "P", "config": {"source": source, "systems": {}},
"details": [], "total": 0, "verified": 0, "present": 0,
"missing": 0, "untested": 0, "mode": "md5"}
return generate_site.generate_platform_page("p", cov)
tag = "https://raw.githubusercontent.com/o/r/batocera-43.1/x/batocera-systems"
self.assertIn(f"| Transcribed from | <{tag}> |", page(tag))
branch = "https://raw.githubusercontent.com/o/r/master/x.json"
self.assertIn("revision read is not recorded", page(branch))
self.assertIn("revision read is not recorded", page("https://github.com/RetroDECK/components"))
if __name__ == "__main__":
unittest.main()