diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index e46a0e44b..8e2f54e29 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -1257,6 +1257,14 @@ def _follow_fork_base( base = upstream.fork_base( view.repo, view.head, source.repo, source.head, cache_dir, offline ) + if base and base != view.pin: + # A pin newer than the merge base names code the port does not + # carry: the upstream is a build of its own, the Qt melonDS or the + # EasyRPG Player a standalone + libretro profile documents, and + # its HEAD stays the reference. melonds read 825 commits back. + moved = upstream.ancestry(view.repo, base, view.pin, cache_dir, offline) + if moved and moved[0] > 0 and moved[1] == 0: + base = None followed.append( replace(view, head=base, origin=f"{view.origin}, fork base of {source.repo.slug}") if base else view diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index 147670577..d28137fb1 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -5465,7 +5465,7 @@ class UpstreamForkedByThePort(unittest.TestCase): upstream with the fork. Compared to upstream's own HEAD, a bump moved it past anything the port carries.""" - def _views(self, base): + def _views(self, base, ancestry=None): from unittest import mock # noqa: PLC0415 fork = profile_sync.upstream.make_repo("github.com", "f", "port") @@ -5477,7 +5477,9 @@ class UpstreamForkedByThePort(unittest.TestCase): ] with mock.patch.object( profile_sync.upstream, "fork_base", return_value=base - ) as asked: + ) as asked, mock.patch.object( + profile_sync.upstream, "ancestry", return_value=ancestry + ): followed = profile_sync._follow_fork_base(views, "cache", True) return followed, asked @@ -5492,6 +5494,17 @@ class UpstreamForkedByThePort(unittest.TestCase): views, _ = self._views(None) self.assertEqual(views[1].head, "up-tip") + def test_a_pin_newer_than_the_base_keeps_the_tip(self): + """melonds documents the Qt standalone from melonDS-emu/melonDS: its + upstream_commit is 825 commits past the merge base with the libretro + fork, and reading its refs at the 2021 base reported them CHANGED.""" + views, _ = self._views("old-merge", ancestry=(825, 0)) + self.assertEqual(views[1].head, "up-tip") + + def test_a_pin_behind_the_base_follows_it(self): + views, _ = self._views("new-base", ancestry=(0, 12)) + self.assertEqual(views[1].head, "new-base") + class ACachedTipOlderThanThePin(TestBuildReport): """scummvm-standalone was pinned on 6f7b060d while the cached tip was