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

+8 -11
View File
@@ -17,7 +17,7 @@ from profiling.anchoring import anchor_block
from profiling.attribution import owner_order
from profiling.citations import Citation, citation_key, collect_citations, is_external_citation
from profiling.proseedit import apply_prose_edits, run_after_moves
from model.profilerepos import declared_repositories
from model.profilerepos import declared_repositories, serving_url
from profiling.yamledit import apply_edit
@@ -359,24 +359,21 @@ def _prose_repos(document: dict) -> _ProseRepos | None:
# Every repository the profile declares, by build mode where it keys
# them so: eka2l1, mesence, supermodel and xemu pin a dict, and reading
# str(dict) found no repository at all, so their prose was never judged.
repos = [
(field, mode, repo)
urls = {
(field, mode, repo): url
for field, mode, url in declared_repositories(document)
if field != "source_mirror" and (repo := upstream.parse_repo(url)) is not None
]
if not repos:
}
if not urls:
return None
repos = list(urls)
# A source declared gone is read through its mirror, which carries the
# same commits: teknoparrot's notes stayed blocked once
# teknogods/TeknoParrotUI answered 404, every reading of the old pin
# calling the files absent.
mirror = (
upstream.parse_repo(str(document.get("source_mirror") or ""))
if document.get("upstream_gone") else None
)
served = {
repo: mirror for field, _mode, repo in repos
if mirror is not None and field == "source"
repo: mirror for (_field, _mode, repo), url in urls.items()
if (mirror := upstream.parse_repo(serving_url(document, url))) not in (None, repo)
}
pinned = [
(served.get(repo, repo), pin)
+21 -2
View File
@@ -7,7 +7,7 @@ from collections.abc import Iterable
from dataclasses import dataclass, replace
from core import upstream
from model.profilerepos import declared_pin, declared_repositories, pin_field
from model.profilerepos import declared_pin, declared_repositories, pin_field, serving_url
PIN = "pin"
@@ -66,6 +66,25 @@ def resolve_pin(
return (sha, f"profiled_date {date}") if sha else (None, None)
def _read_order(profile: dict) -> list[tuple[str, str, str]]:
"""The declared repositories in the order they are asked, as
(field, build mode, url): a source declared gone is followed at once by
the mirror that serves it, before the upstream.
The gone source is still asked, so a forge that answers again
contradicts the declaration. Listed last, the mirror ranked after a live
upstream and took no part in attribution, while the prose pass and the
site read it in the source's place.
"""
order: list[tuple[str, str, str]] = []
for field_name, mode, url in declared_repositories(profile):
order.append((field_name, mode, url))
served = serving_url(profile, url)
if field_name != "source_mirror" and served != url:
order.append(("source_mirror", mode, served))
return order
def select_views(
profile: dict, cache_dir: str, offline: bool
) -> list[RepoView]:
@@ -81,7 +100,7 @@ def select_views(
# A port living on a branch of a fork is absent from the default tip, so
# the branch it was read from is followed when the profile names one.
declared = str(profile.get("source_branch") or "") or None
for field_name, mode, url in declared_repositories(profile):
for field_name, mode, url in _read_order(profile):
repo = upstream.parse_repo(url)
if repo is None or (repo.host, repo.slug) in seen:
continue