fix: check_freshness aligns details after remotes

render padded the local value but not the remote one, so in an area
where some rows carry a remote value their detail started fifteen
columns later than the rows without one. The remote value is padded to
its column, and a row without one leaves the same blank span.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 08:56:32 +01:00
1 parent 8b7e5ceef4
commit 320db75490
2 files changed
+22 -6

No files matched your search

+9 -6
View File
@@ -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())
+13
View File
@@ -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)