fix: name orphaned pins on the triage line

needs_review counts an orphaned pin and a moved repository, but the
triage line only added stale prose and unchecked refs, so pcem read
"1 to review" for an upstream_commit outside its branch history.
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 11:59:33 +01:00
1 parent 739f651a16
commit 593260a5ed
2 files changed
+37 -7

No files matched your search

+24 -7
View File
@@ -1065,6 +1065,29 @@ class ProfileReport:
)
def triage_state(report: ProfileReport) -> str:
"""One triage line: what to review, the pin to set again named first.
A pin outside its branch's history or a repository answering under
another name is fixed before any ref is read: pcem showed as "1 to
review" for an upstream_commit off the dev branch.
"""
if report.skipped:
return report.skipped
state = f"{report.needs_review()} to review"
if report.orphaned:
state += f", {len(report.orphaned)} orphaned pin"
if report.moved_repos:
state += f", {len(report.moved_repos)} repository moved"
stale = len(report.stale_prose or ())
if stale:
state += f", {stale} prose under an older pin"
unchecked = (report.counts or {}).get("UNCHECKED", 0)
if unchecked:
state += f", {unchecked} unchecked"
return state
def select_repo(profile: dict) -> upstream.Repo | None:
"""Repository the profile was read from: source first, then upstream."""
for field in ("source", "upstream"):
@@ -4909,13 +4932,7 @@ def _print_triage(
print(f"{'score':>5s} {'profile':30s} state (worst first)")
pending = 0
for score, report, refused in sorted(ranked, key=lambda item: -item[0]):
state = report.skipped or f"{report.needs_review()} to review"
stale = len(report.stale_prose or ())
if stale and not report.skipped:
state += f", {stale} prose under an older pin"
unchecked = (report.counts or {}).get("UNCHECKED", 0)
if unchecked and not report.skipped:
state += f", {unchecked} unchecked"
state = triage_state(report)
if refused:
state += f", {refused}"
pending += bool(report.needs_review())
+13
View File
@@ -333,6 +333,19 @@ class TestGoneUpstreamIsNotAnError(unittest.TestCase):
self.assertIn("upstream gone", out)
self.assertIn("upstream error", out)
def test_triage_names_an_orphaned_pin_and_a_moved_repository(self):
"""pcem's only problem was an upstream_commit off its dev branch, and
the triage line read "1 to review" like any drift."""
report = ProfileReport(
name="pcem", entries=[], counts={"UNCHECKED": 2},
orphaned=["sarah-walker-pcem/pcem: pin 25b54e3f is no ancestor of 4606fb1e"],
moved_repos=["a/b answers as c/b (renamed or transferred)"],
)
self.assertEqual(
profile_sync.triage_state(report),
"2 to review, 1 orphaned pin, 1 repository moved, 2 unchecked",
)
class TestWorstStatus(unittest.TestCase):
def test_gone_beats_everything(self):