diff --git a/scripts/check_freshness.py b/scripts/check_freshness.py index 3f703d768..2fbee0d48 100644 --- a/scripts/check_freshness.py +++ b/scripts/check_freshness.py @@ -1760,15 +1760,18 @@ def render(findings: list[Finding]) -> str: # Columns are padded, never cut: the profile_sync row says in its # local and remote values what to re-read, and lost the end of it. local_width = min(max((len(f.local) for f in rows), default=0), 44) + remote_width = min(max((len(f.remote) for f in rows), default=0), 44) + # The arrow and the remote value, or as many blanks where a row has none. + remote_span = 4 + remote_width if remote_width else 0 for f in rows: cols = f" {f.status:7} {f.subject:{width}}" if f.remote: - cols += f" {f.local:{local_width}} -> {f.remote}" - elif f.local or (f.detail and local_width): - # An arrow pointing at nothing read as a lost value. An empty - # local value still takes its column, or the detail starts - # where the other rows show theirs. - cols += f" {f.local:{local_width}}" + cols += f" {f.local:{local_width}} -> {f.remote:{remote_width}}" + elif f.local or (f.detail and (local_width or remote_span)): + # An arrow pointing at nothing read as a lost value. Empty + # local and remote values still take their columns, or the + # detail starts where the other rows show theirs. + cols += f" {f.local:{local_width}}" + " " * remote_span if f.detail: cols += f" {f.detail}" lines.append(cols.rstrip()) diff --git a/tests/test_check_freshness.py b/tests/test_check_freshness.py index 9fedcc590..829062f66 100644 --- a/tests/test_check_freshness.py +++ b/tests/test_check_freshness.py @@ -742,6 +742,19 @@ class RowsSayAllTheyStandFor(unittest.TestCase): rows = [line for line in text.splitlines() if line.startswith(" STALE")] self.assertEqual(rows[0].index("no longer"), rows[1].index("is not what")) + def test_a_remote_value_keeps_the_detail_column(self): + """A row with a remote value pushed its detail past the column the + rows without one used, in [coreinfo] by some fifteen characters.""" + text = cf.render([ + cf.Finding("coreinfo", "anybor", cf.STALE, detail="no profile claims"), + cf.Finding("coreinfo", "amiberry", cf.STALE, local="e5d1f0f9a143", + remote="ae545d85c06f", detail=".info changed"), + cf.Finding("coreinfo", "x", cf.STALE, local="abc", remote="d", detail="third"), + ]) + rows = [line for line in text.splitlines() if line.startswith(" STALE")] + columns = {row.index(word) for row, word in zip(rows, ("no profile", ".info", "third"))} + self.assertEqual(len(columns), 1, rows) + def test_json_carries_every_unresolved_name(self): missing = {f"core{i:02d}": [] for i in range(50)} (row,) = cf._unresolved_findings("retropie", missing)