From 2d000b8056e3cf82fd0b2beac5aa3e7120a52a39 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 09:25:23 +0200 Subject: [PATCH] fix: leave mode-keyed pins to a hand edit --- scripts/profile_sync.py | 12 +++++++++--- tests/test_profile_sync.py | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index ef0ba22a..b73a541f 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -2459,6 +2459,15 @@ def bump_commit( if pending_recale(report, accept_changed, text): return False document = yaml.safe_load(text) + if any(isinstance(document.get(f), dict) for f in ("source_commit", "upstream_commit")): + # A pin per build mode names one revision per repository, and the + # report heads only the primary one: rewriting str(dict) was a + # refused write on mesence, supermodel and xemu. + print( + f"{path.stem}: pins keyed by build mode are advanced by hand", + file=sys.stderr, + ) + return False upstream_moves = bool( report.upstream_head and report.upstream_pin != report.upstream_head ) @@ -2466,9 +2475,6 @@ def bump_commit( # Rewriting the pin to the value it already holds is not a bump, and # announcing it buries the profiles that did move. return False - if isinstance(document.get("upstream_commit"), dict): - # A pin per build mode names no single upstream revision to advance. - return False expected = dict(document) expected["source_commit"] = report.head new_text = _set_pin(text, document, "source_commit", report.head, "profiled_date") diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index 61fca2b7..4cbe5f96 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -2510,6 +2510,24 @@ class TestBumpCommit(unittest.TestCase): self.assertEqual(written["source_commit"], "newhead") self.assertEqual(written["upstream_commit"], "uphead") + def test_refused_for_a_pin_keyed_by_build_mode(self): + """mesence, supermodel, xemu: str(dict) never matched a line.""" + text = self.path.read_text(encoding="utf-8") + self.path.write_text( + "source_commit:\n standalone: \"aaa\"\n libretro: \"bbb\"\n" + + "\n".join(l for l in text.splitlines() if not l.startswith("source_commit")) + + "\n", + encoding="utf-8", + ) + report = ProfileReport( + name="p", repo="o/n", pin="aaa", head="newhead", + entries=[], counts={"ANCHORED": 1}, + ) + before = self.path.read_text(encoding="utf-8") + with contextlib.redirect_stderr(io.StringIO()): + self.assertFalse(bump_commit(self.path, report)) + self.assertEqual(self.path.read_text(encoding="utf-8"), before) + def test_refused_when_pinned_to_a_superseded_tag(self): report = ProfileReport( name="p", repo="o/n", pin="pin", head="newhead",