fix: read a source declared gone at its mirror

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:53 +01:00
1 parent ac334729f5
commit 08fbeff62f
7 files changed
+123 -49

No files matched your search

+49
View File
@@ -5871,6 +5871,55 @@ class AMirrorOutlivesAGoneSource(unittest.TestCase):
views = profiling_repos.select_views(profile, "cache", True)
self.assertEqual([(v.repo, v.field) for v in views], [(mirror, "source_mirror")])
def test_the_mirror_takes_the_gone_source_place_before_the_upstream(self):
"""Read last, the mirror ranked after a live upstream, while the
prose pass and the site read it in the source's place."""
from unittest import mock
gone_repo = upstream.make_repo("github.com", "gone", "emu")
mirror = upstream.make_repo("github.com", "fork", "emu")
live = upstream.make_repo("github.com", "up", "emu")
def head(repo, cache_dir, offline=False, branch=None):
if repo == gone_repo:
raise upstream.GoneError("HTTP 404")
return "tip"
profile = {
"source": "https://github.com/gone/emu",
"upstream": "https://github.com/up/emu",
"source_mirror": "https://github.com/fork/emu",
"source_commit": "pin",
"upstream_gone": "gone/emu answers 404",
}
with mock.patch.object(upstream, "resolve_head", side_effect=head), \
mock.patch.object(profiling_repos, "resolve_pin", return_value=("pin", "c")):
views = profiling_repos.select_views(profile, "cache", True)
self.assertEqual([(v.repo, v.field) for v in views],
[(mirror, "source_mirror"), (live, "upstream")])
def test_the_gone_source_is_still_asked(self):
"""A forge answering again contradicts upstream_gone, so it is asked."""
from unittest import mock
asked = []
def head(repo, cache_dir, offline=False, branch=None):
asked.append(repo.slug)
return "tip"
profile = {
"source": "https://github.com/gone/emu",
"source_mirror": "https://github.com/fork/emu",
"source_commit": "pin",
"upstream_gone": "gone/emu answers 404",
}
with mock.patch.object(upstream, "resolve_head", side_effect=head), \
mock.patch.object(profiling_repos, "resolve_pin", return_value=("pin", "c")):
views = profiling_repos.select_views(profile, "cache", True)
self.assertEqual(asked[0], "gone/emu")
self.assertEqual(views[0].field, "source")
class AHeldUpstreamStaysOnItsPin(unittest.TestCase):
"""aps3e vendors RPCS3 1f080485 and yaps2 PCSX2 342db515: a bump moved
+15
View File
@@ -297,6 +297,21 @@ class PerModeSourcePins(unittest.TestCase):
[("gone/emu", "d" * 40), ("keeper/emu", "d" * 40)],
)
def test_a_source_declared_gone_is_linked_through_its_mirror(self):
"""simple64/simple64 answers 404, and every citation on its page
linked there while profile_sync read simple64-vault/simple64."""
profile = {
"source": "https://github.com/gone/emu",
"upstream": "https://github.com/gone/emu",
"source_mirror": "https://github.com/keeper/emu",
"source_commit": "d" * 40,
"upstream_gone": "gone/emu answers 404",
}
self.assertEqual(
[(repo.slug, pin) for repo, pin in _forge_sources(profile)],
[("keeper/emu", "d" * 40)],
)
def test_sqlite_export_accepts_a_per_mode_commit(self):
from core.artifacts import json_text as _json_text