Skip to content

Commit 775fc7f

Browse files
committed
feat: show checked values in the success details block
Each scope line now shows the concrete value that was checked (PR title, commit subject, branch name, author name/email), truncated to one line, so the details block reads like the step log.
1 parent ccbfcd0 commit 775fc7f

2 files changed

Lines changed: 45 additions & 14 deletions

File tree

‎main.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,37 @@ def _markdown_details(results: list[ScopeResult]) -> str:
415415
return "\n".join(sections)
416416

417417

418+
def _scope_value(scope: ScopeResult, max_len: int = 80) -> str:
419+
"""First non-empty check value for a scope, trimmed to a single line.
420+
421+
The value is the concrete thing that was checked (PR title, commit
422+
subject, branch name, author name/email) and reads naturally next to
423+
the scope label in the success details.
424+
"""
425+
for check in scope.checks:
426+
value = check.get("value", "")
427+
if value:
428+
first_line = value.splitlines()[0].strip()
429+
if len(first_line) > max_len:
430+
return first_line[: max_len - 3] + "..."
431+
return first_line
432+
return ""
433+
434+
418435
def _markdown_passed_details(results: list[ScopeResult]) -> str:
419436
"""Render the collapsible section listing passed checks per scope.
420437
421438
Mirrors the step log layout (group name followed by indented ✔ scope
422-
lines) inside a fenced block so it reads like the action log.
439+
lines) inside a fenced block so it reads like the action log. Each
440+
scope line also shows the concrete value that was checked.
423441
"""
424442
lines = ["<details>", "<summary>Show details</summary>", "", "```text"]
425443
for group_name, scopes in _grouped(results):
426444
lines.append(group_name)
427445
for scope in scopes:
428-
lines.append(f" ✔ {scope.label}")
446+
value = _scope_value(scope)
447+
suffix = f" ({value})" if value else ""
448+
lines.append(f" ✔ {scope.label}{suffix}")
429449
lines.extend(["```", "", "</details>"])
430450
return "\n".join(lines)
431451

‎main_test.py‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def json_output(*checks) -> str:
4646
return json.dumps({"status": status, "checks": list(checks)})
4747

4848

49-
def pass_scope(label: str = "Branch") -> main.ScopeResult:
50-
return main.ScopeResult(label=label, checks=[make_check("branch")])
49+
def pass_scope(label: str = "Branch", value: str = "") -> main.ScopeResult:
50+
return main.ScopeResult(label=label, checks=[make_check("branch", value=value)])
5151

5252

5353
def fail_scope(label: str = "Commit 1/1") -> main.ScopeResult:
@@ -630,30 +630,41 @@ def test_raw_text_fallback_is_printed(self):
630630

631631
class TestRenderJobSummary(unittest.TestCase):
632632
def test_all_pass(self):
633-
body = main.render_job_summary([pass_scope("Branch")])
633+
body = main.render_job_summary([pass_scope("Branch", value="main")])
634634
self.assertTrue(body.startswith(main.REPORT_TITLE))
635635
self.assertIn("All checks passed (1 scope)", body)
636636
self.assertIn("<details>", body)
637637
self.assertIn("<summary>Show details</summary>", body)
638638
self.assertIn("```text", body)
639639
self.assertIn("Branch", body)
640-
self.assertIn(" ✔ Branch", body)
640+
self.assertIn(" ✔ Branch (main)", body)
641641

642642
def test_all_pass_groups_scopes_like_step_log(self):
643643
results = [
644-
pass_scope("PR title"),
645-
pass_scope("Commit 1/2"),
646-
pass_scope("Commit 2/2"),
647-
pass_scope("Branch"),
648-
pass_scope("Author name"),
649-
pass_scope("Author email"),
644+
pass_scope("PR title", value="feat: add login page"),
645+
pass_scope("Commit 1/2", value="feat: add user auth"),
646+
pass_scope("Commit 2/2", value="fix: resolve timeout"),
647+
pass_scope("Branch", value="feature/pr-12"),
648+
pass_scope("Author name", value="Jane Doe"),
649+
pass_scope("Author email", value="jane@example.com"),
650650
]
651651
body = main.render_job_summary(results)
652652
# Group headers in the details block mirror the step log ordering.
653653
self.assertLess(body.index("Commit message"), body.index("Branch"))
654654
self.assertLess(body.index("Branch"), body.index("Author"))
655-
for scope in results:
656-
self.assertIn(f" ✔ {scope.label}", body)
655+
self.assertIn(" ✔ PR title (feat: add login page)", body)
656+
self.assertIn(" ✔ Branch (feature/pr-12)", body)
657+
self.assertIn(" ✔ Author email (jane@example.com)", body)
658+
659+
def test_all_pass_truncates_long_values(self):
660+
long_value = "x" * 200
661+
body = main.render_job_summary([pass_scope("Commit 1/1", value=long_value)])
662+
self.assertIn(f" ✔ Commit 1/1 ({'x' * 77}...)", body)
663+
664+
def test_all_pass_without_value_shows_plain_label(self):
665+
body = main.render_job_summary([pass_scope("Branch")])
666+
self.assertIn(" ✔ Branch", body)
667+
self.assertNotIn(" ✔ Branch (", body)
657668

658669
def test_failure_renders_table_with_rule_links(self):
659670
body = main.render_job_summary([fail_scope("Commit 1/1")])

0 commit comments

Comments
 (0)