diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 432f7800..c1e04dad 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -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: diff --git a/tests/test_site_exports.py b/tests/test_site_exports.py index 65a7bbaa..de67ce07 100644 --- a/tests/test_site_exports.py +++ b/tests/test_site_exports.py @@ -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()