feat: follow a fork's base as its upstream head

For a port that is a GitHub fork of its upstream, the upstream code it
carries is the merge base of the two, not upstream's HEAD. The bump moved
upstream_commit to upstream HEAD on snes9x, kronos, np2kai and others
whose pin was that base. The upstream view's head is now the merge base
GitHub's compare names, the way _follow_submodule already reads a
vendored submodule. Outside a fork network the HEAD stays.
This commit is contained in:
Abdessamad Derraz committed 2026-10-23 16:25:56 +02:00
1 parent 01a6daf653
commit 861b89dd44
4 files changed
+116 -1

No files matched your search

+29 -1
View File
@@ -1104,7 +1104,7 @@ def select_views(
continue
seen.add((repo.host, repo.slug))
views.append(RepoView(repo, pin, head, origin, field))
return _follow_submodule(views, cache_dir, offline)
return _follow_fork_base(_follow_submodule(views, cache_dir, offline), cache_dir, offline)
def _follow_submodule(
@@ -1144,6 +1144,34 @@ def _follow_submodule(
return followed
def _follow_fork_base(
views: list[RepoView], cache_dir: str, offline: bool
) -> list[RepoView]:
"""An upstream the port is a fork of moves with what the port merged.
snes9x, kronos, np2kai and six others pinned upstream_commit on the merge
base of upstream with the fork, the upstream code the port carries. Read
against upstream's own HEAD, the bump moved it past anything the port
built from. Outside one fork network the HEAD stays the reference.
"""
source = next((v for v in views if v.field == "source"), None)
if source is None:
return views
followed: list[RepoView] = []
for view in views:
if view.field != "upstream" or view.pin == view.head or " via " in view.origin:
followed.append(view)
continue
base = upstream.fork_base(
view.repo, view.head, source.repo, source.head, cache_dir, offline
)
followed.append(
replace(view, head=base, origin=f"{view.origin}, fork base of {source.repo.slug}")
if base else view
)
return followed
def declared_repositories(profile: dict) -> list[tuple[str, str, str]]:
"""Every repository URL the profile declares, source before upstream.