mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-17 00:43:29 -05:00
fix: pin a source mirror on source_commit
This commit is contained in:
1 parent
3c04a29d50
commit
a41648292e
2 files changed
+35
-2
No files matched your search
@@ -1196,9 +1196,16 @@ def select_views(
|
||||
repo = upstream.parse_repo(url)
|
||||
if repo is None or (repo.host, repo.slug) in seen:
|
||||
continue
|
||||
branch = branch_in_url(url) or (declared if field == "source" else None)
|
||||
# A mirror carries the source's history, commits and branches alike:
|
||||
# its pin is source_commit. It read `source_mirror_commit`, a field
|
||||
# no profile carries, and fell back to profiled_date, which a bump
|
||||
# never moves (eden judged from f6e76860 while pinned on d16735f5).
|
||||
pin_field = "source" if field == "source_mirror" else field
|
||||
branch = branch_in_url(url) or (
|
||||
declared if pin_field == "source" else None
|
||||
)
|
||||
pin, origin = resolve_pin(
|
||||
profile, repo, cache_dir, offline, field, mode, branch
|
||||
profile, repo, cache_dir, offline, pin_field, mode, branch
|
||||
)
|
||||
if not pin:
|
||||
continue
|
||||
|
||||
@@ -250,6 +250,32 @@ class TestSourceMirror(unittest.TestCase):
|
||||
[("source_mirror", "", "https://codeberg.org/o/mirror")],
|
||||
)
|
||||
|
||||
def test_the_mirror_reads_the_source_pin(self):
|
||||
"""eden's mirror was judged from profiled_date while source_commit,
|
||||
which bumps advance, named another revision."""
|
||||
profile = {
|
||||
"source": "https://git.eden-emu.dev/o/port",
|
||||
"source_mirror": "https://codeberg.org/o/mirror",
|
||||
"source_commit": "d16735f5",
|
||||
"profiled_date": "2026-03-26",
|
||||
"source_branch": "dev",
|
||||
}
|
||||
calls = []
|
||||
|
||||
def head(repo, cache_dir, offline, branch=None):
|
||||
calls.append(("head", repo.host, branch))
|
||||
return None if repo.host == "git.eden-emu.dev" else "tip"
|
||||
|
||||
def at(*args, **kwargs):
|
||||
raise AssertionError("a declared pin needs no date lookup")
|
||||
|
||||
with mock.patch.object(profile_sync.upstream, "resolve_head", head), \
|
||||
mock.patch.object(profile_sync.upstream, "resolve_commit_at", at):
|
||||
views = profile_sync.select_views(profile, "unused", True)
|
||||
self.assertEqual([(v.repo.host, v.pin) for v in views],
|
||||
[("codeberg.org", "d16735f5")])
|
||||
self.assertIn(("head", "codeberg.org", "dev"), calls)
|
||||
|
||||
def test_a_profile_without_a_mirror_is_unchanged(self):
|
||||
profile = {"source": "https://github.com/o/port"}
|
||||
self.assertEqual(
|
||||
|
||||
Reference in new issue
Block a user