fix: stop the MAME scrape on a clone with no pin

A failed rev-parse in the MAME clone returned an empty commit, which
was cached for a day and let the merge advance the profile's version
and refs while its upstream pin stayed on the previous release. The
scrape now stops instead.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 05:15:52 +02:00
1 parent baf635cf4e
commit e04646d67a
2 files changed
+35 -3

No files matched your search

+14 -3
View File
@@ -157,11 +157,22 @@ def _parse_version_tag(tag: str) -> str:
def _get_commit() -> str:
"""The commit the clone holds, or an error: never an empty pin.
Returned empty, it was cached for a day and the merge advanced
core_version and the refs to the new release while upstream_commit
stayed on the old one, a profile describing two revisions at once.
"""
try:
result = _run_git(["rev-parse", "HEAD"], cwd=_CLONE_DIR)
return result.stdout.strip()
except subprocess.CalledProcessError:
return ""
except subprocess.CalledProcessError as exc:
raise RuntimeError(
f"cannot read the commit of the MAME clone in {_CLONE_DIR}: {exc}"
) from exc
commit = result.stdout.strip()
if not commit:
raise RuntimeError(f"the MAME clone in {_CLONE_DIR} names no commit")
return commit
def _cleanup() -> None:
+21
View File
@@ -685,5 +685,26 @@ class TestDerivativeVersion(unittest.TestCase):
self.assertEqual(entry["source_ref"], "src/mame/philips/cdi.cpp:484")
class AnUnreadableCloneStopsTheScrape(unittest.TestCase):
"""_get_commit swallowed a failed rev-parse and returned "": cached for a
day, the merge then advanced core_version and the refs while
upstream_commit stayed on the previous release."""
def test_no_empty_commit_reaches_the_cache(self):
import subprocess
from unittest import mock
from scripts.scraper import mame_hash_scraper as scraper
failing = subprocess.CalledProcessError(128, ["git", "rev-parse", "HEAD"])
with mock.patch.object(scraper, "_run_git", side_effect=failing):
with self.assertRaises(RuntimeError):
scraper._get_commit()
empty = subprocess.CompletedProcess(["git"], 0, stdout="\n", stderr="")
with mock.patch.object(scraper, "_run_git", return_value=empty):
with self.assertRaises(RuntimeError):
scraper._get_commit()
if __name__ == "__main__":
unittest.main()