mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-09 03:23:47 -06:00
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:
1 parent
baf635cf4e
commit
e04646d67a
2 files changed
+35
-3
No files matched your search
@@ -157,11 +157,22 @@ def _parse_version_tag(tag: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _get_commit() -> 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:
|
try:
|
||||||
result = _run_git(["rev-parse", "HEAD"], cwd=_CLONE_DIR)
|
result = _run_git(["rev-parse", "HEAD"], cwd=_CLONE_DIR)
|
||||||
return result.stdout.strip()
|
except subprocess.CalledProcessError as exc:
|
||||||
except subprocess.CalledProcessError:
|
raise RuntimeError(
|
||||||
return ""
|
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:
|
def _cleanup() -> None:
|
||||||
|
|||||||
@@ -685,5 +685,26 @@ class TestDerivativeVersion(unittest.TestCase):
|
|||||||
self.assertEqual(entry["source_ref"], "src/mame/philips/cdi.cpp:484")
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in new issue
Block a user