fix: leave mode-keyed pins to a hand edit

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 09:25:23 +02:00
1 parent 5bf25d1964
commit 2d000b8056
2 files changed
+27 -3

No files matched your search

+9 -3
View File
@@ -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")
+18
View File
@@ -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",