mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-21 19:29:03 -05:00
fix: name every pin a bump changes
This commit is contained in:
1 parent
67c199c9f1
commit
4521edca59
3 files changed
+39
-6
No files matched your search
+15
-5
@@ -2885,6 +2885,14 @@ def bump_commit(
|
||||
return True
|
||||
|
||||
|
||||
def pins_changed(before: dict, after: dict) -> list[str]:
|
||||
"""The pin fields whose value a write changed."""
|
||||
return [
|
||||
pin for pin in ("source_commit", "upstream_commit")
|
||||
if after.get(pin) and after.get(pin) != before.get(pin)
|
||||
]
|
||||
|
||||
|
||||
def cites_primary(report: ProfileReport) -> bool:
|
||||
"""Whether a ref resolved in the repository source_commit pins.
|
||||
|
||||
@@ -3480,10 +3488,7 @@ def _apply_writes(
|
||||
# refs at the old pin and saw them shifted again.
|
||||
target = Path(scratch) / path.name
|
||||
target.write_bytes(path.read_bytes())
|
||||
recale, bumped = (
|
||||
("would recale ", "would set source_commit ->") if args.dry_run
|
||||
else ("", "source_commit ->")
|
||||
)
|
||||
recale, bumped = ("would recale ", "would set ") if args.dry_run else ("", "")
|
||||
applied = []
|
||||
if args.rebase_refs and not report.skipped:
|
||||
applied = rebase_refs(target, report, args.accept_changed)
|
||||
@@ -3498,7 +3503,12 @@ def _apply_writes(
|
||||
for line in applied:
|
||||
print(f"{name}: {recale}{line}")
|
||||
if moved:
|
||||
print(f"{name}: {bumped} {report.head[:7]}")
|
||||
# Each pin the write changes, as written: a bump that only moved
|
||||
# upstream_commit announced the source_commit it already held.
|
||||
after = yaml.safe_load(target.read_text(encoding="utf-8")) or {}
|
||||
before = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
||||
for pin in pins_changed(before, after):
|
||||
print(f"{name}: {bumped}{pin} -> {str(after[pin])[:7]}")
|
||||
if not args.dry_run and (applied or moved):
|
||||
path.write_bytes(target.read_bytes())
|
||||
|
||||
|
||||
@@ -2494,6 +2494,28 @@ class TestWriteDryRun(unittest.TestCase):
|
||||
self.assertIn("would set source_commit -> newhead", output)
|
||||
self.assertEqual(self.path.read_text(), before)
|
||||
|
||||
def test_a_bump_that_moves_only_upstream_says_so(self):
|
||||
"""rustation: source_commit already at HEAD, the write added
|
||||
upstream_commit, and the dry run announced the source_commit it
|
||||
already held."""
|
||||
self.path.write_text(
|
||||
self.path.read_text().replace(
|
||||
'profiled_date: "2026-03-29"',
|
||||
'profiled_date: "2026-03-29"\nsource_commit: "newhead"',
|
||||
)
|
||||
)
|
||||
part = PartResult(
|
||||
RefPart("a.c", 10, 12, "a.c:10-12"), "ANCHORED", None, 10, 12, []
|
||||
)
|
||||
report = ProfileReport(
|
||||
name="p", repo="o/n", pin="newhead", head="newhead",
|
||||
entries=[EntryReport("a.bin", "a.c:10-12", "ANCHORED", [part])],
|
||||
counts={"ANCHORED": 1}, upstream_pin="oldup", upstream_head="uphead",
|
||||
)
|
||||
output = self._run(self._args(bump_commit=True), report)
|
||||
self.assertIn("would set upstream_commit -> uphead", output)
|
||||
self.assertNotIn("source_commit ->", output)
|
||||
|
||||
def test_writes_still_happen_without_the_flag(self):
|
||||
output = self._run(
|
||||
self._args(rebase_refs=True, dry_run=False), self._shifted()
|
||||
|
||||
+2
-1
@@ -411,7 +411,8 @@ pass cannot rewrite without guessing: those are repaired first, by hand or
|
||||
with `--realign-prose`.
|
||||
|
||||
The first prints the plan and changes nothing: `would recale` per ref and
|
||||
`would set source_commit` per profile. It reaches that plan by running the
|
||||
`would set source_commit` (and `upstream_commit`, when that one moves too)
|
||||
per pin the write changes. It reaches that plan by running the
|
||||
real write path over a throwaway copy, so the planned bump reads the text
|
||||
the recale would have left rather than the one on disk; a pin held back by
|
||||
prose that the same pass would have moved is not reported as blocked. Drop
|
||||
|
||||
Reference in new issue
Block a user