From 7c0515f9b8adb94366f01ce850ff1102c6ba1385 Mon Sep 17 00:00:00 2001
From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Date: Mon, 23 Nov 2026 20:33:59 +0000
Subject: [PATCH 1/4] fix: line up list values in the listing and say "1 check"
The declaration boxes CC501 reports are a list. The second box sat at the
column of "value:" and read as a line of its own, so list continuation
lines now align under the first item. A commit body in the value stays
flush, as before.
The folded listing's title said "All 1 check" for a single check; it
now says "1 check".
---
action/render.py | 21 ++++++++++++++++++---
tests/log_test.py | 38 ++++++++++++++++++++++++++++++++++++++
tests/report_test.py | 6 +++---
3 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/action/render.py b/action/render.py
index eca1d9c..bbf1099 100644
--- a/action/render.py
+++ b/action/render.py
@@ -452,12 +452,20 @@ def _finding_lines(check: dict[str, str]) -> list[str]:
message; a multi-line value (a whole commit message on a failing rule)
or suggestion is split the same way, so every line of user text sits
inside the tree rather than at column 0.
+
+ A value that is a list (the declaration boxes CC501 found in a PR
+ description) is aligned under its first item instead, so the second box
+ does not read as a line of its own. A commit message stays flush: its
+ body is prose, and the blank line already sets it apart.
"""
lines: list[str] = []
if check.get("value"):
first, *rest = str(check["value"]).splitlines()
lines.append(f"value: {first}")
- lines.extend(rest)
+ if _is_list([first, *rest]):
+ lines.extend(f"{'':7}{line}" for line in rest)
+ else:
+ lines.extend(rest)
lines.extend(check.get("error", "").splitlines())
fix = check.get("fix", "")
suggest = check.get("suggest", "")
@@ -472,6 +480,11 @@ def _finding_lines(check: dict[str, str]) -> list[str]:
return lines
+def _is_list(lines: list[str]) -> bool:
+ """Whether every line is a Markdown list item (``- [ ] ...``, ``* ...``)."""
+ return all(line.lstrip().startswith(("- ", "* ", "+ ")) for line in lines)
+
+
def _render_findings(checks: list[dict[str, str]], include_docs: bool) -> list[str]:
"""Render the indented detail lines for a list of check entries.
@@ -1072,8 +1085,10 @@ def _all_checks(results: list[model.ScopeResult]) -> list[str]:
and why". The same block is used whether or not anything failed.
"""
_failed, total = _check_counts(results)
- unit = "check" if total == 1 else "checks"
- label = f"All {total} {unit}" if total else "Details"
+ if total > 1:
+ label = f"All {total} checks"
+ else:
+ label = "1 check" if total else "Details"
body = _fenced("text", _render_tree(results, include_docs=False))
return ["", f"{label}
", "", *body, "", " "]
diff --git a/tests/log_test.py b/tests/log_test.py
index 5ac0ed6..c579118 100644
--- a/tests/log_test.py
+++ b/tests/log_test.py
@@ -149,6 +149,44 @@ def test_finding_lines_are_the_value_the_error_and_the_fix(self):
],
)
+ def test_a_list_value_lines_up_under_its_first_item(self):
+ """The second declaration box would otherwise sit at the column of
+ ``value:`` and read as a line of its own."""
+ check = make_check(
+ "ai_declaration",
+ status="fail",
+ rule_id="CC501",
+ value="- [ ] No AI tools were used\n- [ ] AI tools were used",
+ error="No AI declaration box is ticked",
+ )
+ self.assertEqual(
+ render._finding_lines(check),
+ [
+ "value: - [ ] No AI tools were used",
+ " - [ ] AI tools were used",
+ "No AI declaration box is ticked",
+ ],
+ )
+
+ def test_a_commit_body_in_the_value_stays_flush(self):
+ """A commit message is prose: its body is not indented."""
+ check = make_check(
+ "message",
+ status="fail",
+ rule_id="CC001",
+ value="added login page\n\nIt also fixes the redirect.",
+ error="The commit message should follow Conventional Commits.",
+ )
+ self.assertEqual(
+ render._finding_lines(check),
+ [
+ "value: added login page",
+ "",
+ "It also fixes the redirect.",
+ "The commit message should follow Conventional Commits.",
+ ],
+ )
+
def test_annotation_without_an_error_still_names_the_kind_of_finding(self):
scope = model.ScopeResult(
label="Branch",
diff --git a/tests/report_test.py b/tests/report_test.py
index 4789534..b718195 100644
--- a/tests/report_test.py
+++ b/tests/report_test.py
@@ -346,7 +346,7 @@ def test_total_does_not_grow_with_the_number_of_rules(self):
for results in (one_rule, many_rules):
body = render.render_report(results)
self.assertIn("> Branch: passed\n", body)
- self.assertIn("All 1 check", body)
+ self.assertIn("1 check", body)
def test_body_opens_with_hidden_marker(self):
body = render.render_job_summary([pass_scope("Branch")])
@@ -369,7 +369,7 @@ def test_all_pass(self):
body = render.render_job_summary([pass_scope("Branch", value="main")])
self.assertIn("Commit Check passed\n", body)
self.assertIn("", body)
- self.assertIn("All 1 check
", body)
+ self.assertIn("1 check
", body)
self.assertIn("```text", body)
self.assertIn("\nBranch\n ✔ branch main\n", body)
self.assertNotIn("```diff", body)
@@ -418,7 +418,7 @@ def test_failure_shows_the_diff_and_the_rule_links(self):
self.assertIn(
"Rules: [CC001](https://commit-check.com/rules/#cc001)", body
)
- self.assertIn("All 1 check
", body)
+ self.assertIn("1 check
", body)
self.assertIn(" ✖ 1/1 bad message\n", body)
self.assertIn(" CC001 message", body)
self.assertIn(" value: bad message", body)
From df2f06f84d46461799609e1b55d74980800e5b5b Mon Sep 17 00:00:00 2001
From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Date: Mon, 23 Nov 2026 20:41:37 +0000
Subject: [PATCH 2/4] fix: line up a commit body under its subject too
Align every multi-line value, not only lists, so a commit body reads as
one block and the rule's error after it is not taken for part of the
message. Blank lines stay empty.
---
action/render.py | 18 +++++-------------
tests/log_test.py | 7 ++++---
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/action/render.py b/action/render.py
index bbf1099..3c72fc3 100644
--- a/action/render.py
+++ b/action/render.py
@@ -453,19 +453,16 @@ def _finding_lines(check: dict[str, str]) -> list[str]:
or suggestion is split the same way, so every line of user text sits
inside the tree rather than at column 0.
- A value that is a list (the declaration boxes CC501 found in a PR
- description) is aligned under its first item instead, so the second box
- does not read as a line of its own. A commit message stays flush: its
- body is prose, and the blank line already sets it apart.
+ The rest of a multi-line value (a commit body, the second declaration
+ box CC501 found) is aligned under its first line, so the value reads as
+ one block and the error after it is not mistaken for part of it. A blank
+ line stays empty, with no trailing spaces.
"""
lines: list[str] = []
if check.get("value"):
first, *rest = str(check["value"]).splitlines()
lines.append(f"value: {first}")
- if _is_list([first, *rest]):
- lines.extend(f"{'':7}{line}" for line in rest)
- else:
- lines.extend(rest)
+ lines.extend(f"{'':7}{line}" if line else "" for line in rest)
lines.extend(check.get("error", "").splitlines())
fix = check.get("fix", "")
suggest = check.get("suggest", "")
@@ -480,11 +477,6 @@ def _finding_lines(check: dict[str, str]) -> list[str]:
return lines
-def _is_list(lines: list[str]) -> bool:
- """Whether every line is a Markdown list item (``- [ ] ...``, ``* ...``)."""
- return all(line.lstrip().startswith(("- ", "* ", "+ ")) for line in lines)
-
-
def _render_findings(checks: list[dict[str, str]], include_docs: bool) -> list[str]:
"""Render the indented detail lines for a list of check entries.
diff --git a/tests/log_test.py b/tests/log_test.py
index c579118..ea2abe3 100644
--- a/tests/log_test.py
+++ b/tests/log_test.py
@@ -168,8 +168,9 @@ def test_a_list_value_lines_up_under_its_first_item(self):
],
)
- def test_a_commit_body_in_the_value_stays_flush(self):
- """A commit message is prose: its body is not indented."""
+ def test_a_commit_body_lines_up_under_the_subject(self):
+ """The body sits under the subject, so the error after it is not
+ read as a line of the message. The blank line stays empty."""
check = make_check(
"message",
status="fail",
@@ -182,7 +183,7 @@ def test_a_commit_body_in_the_value_stays_flush(self):
[
"value: added login page",
"",
- "It also fixes the redirect.",
+ " It also fixes the redirect.",
"The commit message should follow Conventional Commits.",
],
)
From be6f48f4be47e0b00a528776504031fd3ed98ac9 Mon Sep 17 00:00:00 2001
From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Date: Mon, 23 Nov 2026 20:42:14 +0000
Subject: [PATCH 3/4] fix: leave blank lines in the listing empty
A blank line inside a value or a fix (the gap before a body or a
Signed-off-by trailer) carried eight trailing spaces.
---
action/render.py | 2 +-
tests/log_test.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/action/render.py b/action/render.py
index 3c72fc3..1f9a0b2 100644
--- a/action/render.py
+++ b/action/render.py
@@ -490,7 +490,7 @@ def _render_findings(checks: list[dict[str, str]], include_docs: bool) -> list[s
# warning says so on its own line rather than borrow the row's mark.
kind = " (warning)" if check.get("status") == "warn" else ""
lines.append(f" {_rule_label(check)}{kind}")
- lines.extend(f" {line}" for line in _finding_lines(check))
+ lines.extend(f" {line}" if line else "" for line in _finding_lines(check))
if include_docs and check.get("docs_url"):
lines.append(f" Docs: {check['docs_url']}")
return lines
diff --git a/tests/log_test.py b/tests/log_test.py
index ea2abe3..b5e5d57 100644
--- a/tests/log_test.py
+++ b/tests/log_test.py
@@ -259,7 +259,7 @@ def test_a_multi_line_fix_takes_one_row_per_line(self):
listing = output.split("::endgroup::")[0]
self.assertIn(
" Fix: feat: add login page\n"
- " \n"
+ "\n"
" Signed-off-by: Jane Doe \n",
listing,
)
From bd89efba32806eadde5e07c8c1fd6aef864fc62d Mon Sep 17 00:00:00 2001
From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Date: Mon, 23 Nov 2026 20:42:24 +0000
Subject: [PATCH 4/4] style: format render.py
---
action/render.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/action/render.py b/action/render.py
index 1f9a0b2..29fc48b 100644
--- a/action/render.py
+++ b/action/render.py
@@ -490,7 +490,9 @@ def _render_findings(checks: list[dict[str, str]], include_docs: bool) -> list[s
# warning says so on its own line rather than borrow the row's mark.
kind = " (warning)" if check.get("status") == "warn" else ""
lines.append(f" {_rule_label(check)}{kind}")
- lines.extend(f" {line}" if line else "" for line in _finding_lines(check))
+ lines.extend(
+ f" {line}" if line else "" for line in _finding_lines(check)
+ )
if include_docs and check.get("docs_url"):
lines.append(f" Docs: {check['docs_url']}")
return lines