From 856cb5618fcbed70c834a74da1b8be521e25bce5 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:14:42 +0100 Subject: [PATCH] fix: link a build file only where it is recorded Every source link on the site leads to a path the source record saw at a commit. The Build file row linked pin_build files unchecked, eight of them at commits the record did not hold. build_source_paths now records the build files read at a commit, and the row links only those: a tag can move and stays plain text. The record run also picked up two cited paths it had not seen before (pom2 CMakeLists.txt, pcem configure.ac). --- scripts/generate_site.py | 13 ++++++++----- scripts/sitesources.py | 19 +++++++++++++++++++ tests/test_audit_regressions.py | 27 +++++++++++++++++++++++---- website/src/data/source-paths.json | 14 ++++++++++++++ 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index fe43620af..127c8aa3e 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -8198,17 +8198,20 @@ def _exact_size(size: int) -> str: def _build_file_links(pin_build: list[dict]) -> list[str]: """Each platform build file that holds the revision, linked at the - revision it was read at. The prose of pin_frozen named the file as - plain text, while pin_build carries all a pinned link needs.""" - from sitesources import _browse_repo, _source_permalink # noqa: PLC0415 + commit it was read at when the source record holds it. The prose of + pin_frozen named the file as plain text.""" + from sitesources import _browse_repo, _source_permalink, tree_holds # noqa: PLC0415 links = [] for build in pin_build: repo = _browse_repo(str(build["repo"])) path = str(build["path"]) + revision = str(build["revision"]) text = f"{_escape_tags(_platform_display(str(build['platform'])))} {_code(path)}" - if repo is not None: - text = f"[{text}]({_source_permalink(repo, str(build['revision']), path, None, None)})" + # Linked where the record saw the file at that commit, as every + # source link is: a tag can move, and is never recorded. + if repo is not None and tree_holds(repo, revision, path): + text = f"[{text}]({_source_permalink(repo, revision, path, None, None)})" links.append(f"{text} at {_code(str(build['revision']))} sets {_code(str(build['variable']))}") return links diff --git a/scripts/sitesources.py b/scripts/sitesources.py index f42de04ae..c28b7c5f1 100644 --- a/scripts/sitesources.py +++ b/scripts/sitesources.py @@ -321,9 +321,28 @@ def build_source_paths( # Recorded even when it holds no cited path, so a pinned tree # missing from the record is one no run has read. held.setdefault(tree_key(repo, pin), set()).update(paths & tree) + for repo, pin, path in build_files(profile): + tree = (_cached_tree(repo, pin, cache_dirs, fetch) + or _listed_directories(repo, pin, {path}, cache_dirs, fetch)) + if tree is None: + unread.add(tree_key(repo, pin)) + continue + held.setdefault(tree_key(repo, pin), set()).update({path} & tree) return {key: sorted(paths) for key, paths in sorted(held.items())}, sorted(unread) +def build_files(profile: dict) -> list[tuple[upstream.Repo, str, str]]: + """The platform build files `pin_build` names at a commit, as (repo, + revision, path). A tag can move, so a build read at a tag is not linked.""" + found = [] + for build in profile.get("pin_build") or []: + repo = _browse_repo(str(build.get("repo", ""))) + revision = str(build.get("revision", "")) + if repo is not None and re.fullmatch(r"[0-9a-f]{40}", revision): + found.append((repo, revision, str(build.get("path", "")))) + return found + + def keep_unread( held: dict[str, list[str]], unread: list[str], previous: dict[str, list[str]] ) -> dict[str, list[str]]: diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 6776263b8..da75706d6 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5222,11 +5222,30 @@ class AHeldRevisionLinksItsBuildFile(unittest.TestCase): "platform": "knulli", "repo": "https://github.com/knulli-cfw/knulli-linux", "revision": "20260511", "path": "package/emulators/advanced_drastic/advanced_drastic.mk", "variable": "ADVANCED_DRASTIC_VERSION", "value": "eaf41ab9"}]}) + # A tag can move: named, never linked. self.assertIn( - "| Build file | [KNULLI `package/emulators/advanced_drastic/advanced_drastic.mk`]" - "(https://github.com/knulli-cfw/knulli-linux/blob/20260511/package/emulators/" - "advanced_drastic/advanced_drastic.mk) at `20260511` sets `ADVANCED_DRASTIC_VERSION` |", - rows) + "| Build file | KNULLI `package/emulators/advanced_drastic/advanced_drastic.mk` " + "at `20260511` sets `ADVANCED_DRASTIC_VERSION` |", rows) + + def test_a_build_read_at_a_recorded_commit_links(self): + from scripts.generate_site import _build_rows + + pin = "46128cd252cdecae852a4d0bafa2aaf9d03ab563" + rows = _build_rows({"pin_build": [{ + "platform": "retropie", "repo": "https://github.com/RetroPie/RetroPie-Setup", + "revision": pin, "path": "scriptmodules/emulators/advmame-1.4.sh", + "variable": "rp_module_repo", "value": "x"}]}) + self.assertIn( + f"[RetroPie `scriptmodules/emulators/advmame-1.4.sh`](https://github.com/RetroPie/" + f"RetroPie-Setup/blob/{pin}/scriptmodules/emulators/advmame-1.4.sh)", rows[0]) + + def test_the_record_holds_the_build_files(self): + import sitesources # noqa: PLC0415 + + files = sitesources.build_files({"pin_build": [ + {"repo": "https://github.com/o/r", "revision": "a" * 40, "path": "p.mk"}, + {"repo": "https://github.com/o/r", "revision": "v1", "path": "q.mk"}]}) + self.assertEqual([(f[1], f[2]) for f in files], [("a" * 40, "p.mk")]) class AVariantCardSaysWhatToSaveItAs(unittest.TestCase): diff --git a/website/src/data/source-paths.json b/website/src/data/source-paths.json index d591448f7..d0f00e7a2 100644 --- a/website/src/data/source-paths.json +++ b/website/src/data/source-paths.json @@ -424,6 +424,11 @@ "crates/wqxemu/src/keypad.rs", "crates/wqxemu/src/main.rs" ], + "github.com/AmberELEC/AmberELEC@a21975bfb1a3af68f66e07a931b994b523e1e6e2": [ + "packages/games/emulators/lzdoom/package.mk", + "packages/games/emulators/piemu/package.mk", + "packages/games/libretro/flycast2021le/package.mk" + ], "github.com/Amjad50/plastic@74152adb3acd890d3abee2ff5906408f26a199e2": [ "plastic_core/src/cartridge/mod.rs", "plastic_core/src/display/color.rs", @@ -1584,6 +1589,13 @@ "imagine/src/font/FreetypeFont.cc", "imagine/src/fs/ArchiveFS.cc" ], + "github.com/RetroPie/RetroPie-Setup@46128cd252cdecae852a4d0bafa2aaf9d03ab563": [ + "scriptmodules/emulators/advmame-1.4.sh", + "scriptmodules/emulators/ppsspp-1.5.4.sh", + "scriptmodules/ports/alephone.sh", + "scriptmodules/ports/love-0.10.2.sh", + "scriptmodules/ports/lzdoom.sh" + ], "github.com/RetroPie/mame4all-pi@c6bfd2aef331b5a5e157c15d8bf8a77393c85689": [ "readme.txt", "src/cheat.cpp", @@ -3475,6 +3487,7 @@ "src/ui/video.rs" ], "github.com/habib256/pom2@de86e8e35df96fe6ffced56dfb727bbd567f8568": [ + "CMakeLists.txt", "packaging/bundle.manifest", "packaging/fujinet/stage.py", "src/AppleParallelCard.cpp", @@ -8930,6 +8943,7 @@ "nes.c" ], "github.com/sarah-walker-pcem/pcem@10739b9618e388a5bf8c21e752f12b3952fa83e1": [ + "configure.ac", "src/mem.c", "src/nvr.c", "src/ps1.c",