diff --git a/README.md b/README.md index 6708764..8409d4b 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ commit and rule is linked under it, and two folds hold the rest: how to fix it > ✖ **Commit Check failed** > -> ✔ Pull request: passed
-> ✖ Commits: 1 of 2 failed
-> ✖ Branch: failed +> ✔ Pull request: passed
+> ✖ Commits: 1 of 2 failed
+> ✖ Branch: failed > > ```diff > @@ 5584f46 @@ diff --git a/main.py b/main.py index 6948fc0..73afd67 100755 --- a/main.py +++ b/main.py @@ -1826,17 +1826,28 @@ def _fenced(language: str, body: list[str]) -> list[str]: def _status_mark(status: str, size: int, line: bool = False) -> str: - """The ```` of a status mark: the tile at 24 px, the line mark at 16.""" + """The ```` of a status mark: the tile at 24 px, the line mark at 16. + + The tile sits at the top of the heading. A line mark is centred on its + line of text (``absmiddle``): aligned to the top it rode about two pixels + above the words beside it. + """ name = f"{'line-' if line else ''}{STATUS_WORDS[status]}" + align = "absmiddle" if line else "top" return ( f'{STATUS_GLYPHS[status]}' + f'align="{align}" src="{STATUS_MARK_URL}/{name}.png">' ) def _group_lines(results: list[ScopeResult]) -> str: - """One line per group, its status mark in front: the overview.""" - return "
\n".join( + """One line per group, its status mark in front: the overview. + + The lines are joined by ``
`` alone, on one source line. A pull request + comment turns every newline into a line break of its own, so ``
`` + followed by a newline left an empty line between the groups there. + """ + return "
".join( f"{_status_mark(status, 16, line=True)} {group_name}: {text}" for group_name, scopes in _grouped(results) for status, text in [_group_status(scopes)] @@ -2087,9 +2098,8 @@ def _all_checks(results: list[ScopeResult]) -> list[str]: # # ## Commit Check failed # -# Pull request: passed
-# Commits: 2 of 3 failed
-# Branch: failed +# Pull request: passed
Commits: 2 of 3 failed
Branch: failed +# (one source line: see _group_lines) # # ```diff # @@ 5584f46 @@ diff --git a/main_test.py b/main_test.py index a1016e5..23b98e3 100644 --- a/main_test.py +++ b/main_test.py @@ -43,7 +43,7 @@ def heading(glyph: str, word: str, verdict: str) -> str: def group_line(glyph: str, word: str, text: str) -> str: """One group's line of the report: its line mark, name and result.""" return ( - f'{glyph} {text}' ) @@ -2005,8 +2005,8 @@ def test_success_golden_output(self): f"{main.COMMENT_MARKER}\n" f"{heading('✔', 'passed', 'passed')}\n" "\n" - f"{group_line('✔', 'passed', 'Pull request: passed')}
\n" - f"{group_line('✔', 'passed', 'Commits: 2 passed')}
\n" + f"{group_line('✔', 'passed', 'Pull request: passed')}
" + f"{group_line('✔', 'passed', 'Commits: 2 passed')}
" f"{group_line('✔', 'passed', 'Branch: passed')}\n" "\n" "
\n" @@ -2042,8 +2042,8 @@ def test_failure_golden_output(self): f"{main.COMMENT_MARKER}\n" f"{heading('✖', 'failed', 'failed')}\n" "\n" - f"{group_line('✔', 'passed', 'Pull request: passed')}
\n" - f"{group_line('✖', 'failed', 'Commits: failed')}
\n" + f"{group_line('✔', 'passed', 'Pull request: passed')}
" + f"{group_line('✖', 'failed', 'Commits: failed')}
" f"{group_line('✔', 'passed', 'Branch: passed')}\n" "\n" "```diff\n" @@ -2118,8 +2118,8 @@ def test_failure_golden_output_with_commits(self): f"{main.COMMENT_MARKER}\n" f"{heading('✖', 'failed', 'failed')}\n" "\n" - f"{group_line('✔', 'passed', 'Pull request: passed')}
\n" - f"{group_line('✖', 'failed', 'Commits: 2 of 3 failed')}
\n" + f"{group_line('✔', 'passed', 'Pull request: passed')}
" + f"{group_line('✖', 'failed', 'Commits: 2 of 3 failed')}
" f"{group_line('✔', 'passed', 'Branch: passed')}\n" "\n" "```diff\n" @@ -3721,7 +3721,7 @@ def test_all_skipped_golden_output(self): "\n" "Nothing was validated.\n" "\n" - f"{group_line('⊘', 'skipped', 'Pull request: skipped')}
\n" + f"{group_line('⊘', 'skipped', 'Pull request: skipped')}
" f"{group_line('⊘', 'skipped', 'Commits: skipped')}\n" "\n" "
\n" @@ -3744,7 +3744,7 @@ def test_partial_skip_does_not_claim_all_passed(self): results.append(pass_scope("PR description")) body = main.render_report(results) self.assertIn("Commit Check passed\n", body) - self.assertIn("> Branch: passed
\n", body) + self.assertIn("> Branch: passed
", body) # Two scopes in the group, one of which ran: never "2 passed". self.assertIn("> Pull request: 1 passed, 1 skipped\n", body) @@ -3752,7 +3752,7 @@ def test_failure_still_wins_over_skips(self): results = [fail_scope("Commit 1/1"), skip_scope("PR title")] body = main.render_report(results) self.assertIn("Commit Check failed\n", body) - self.assertIn("> Commits: failed
\n", body) + self.assertIn("> Commits: failed
", body) self.assertIn("> Pull request: skipped\n", body) def test_skipped_scope_reports_no_checked_value(self): @@ -3993,7 +3993,7 @@ def test_warning_only_golden_output(self): f"{main.COMMENT_MARKER}\n" f"{heading('⚠', 'warned', 'passed with warnings')}\n" "\n" - f"{group_line('✔', 'passed', 'Pull request: passed')}
\n" + f"{group_line('✔', 'passed', 'Pull request: passed')}
" f"{group_line('⚠', 'warned', 'Branch: 1 warning')}\n" "\n" "**Warnings**\n" @@ -4030,8 +4030,8 @@ def test_warning_and_skip_each_get_their_own_group_line(self): body = main.render_report(results) self.assertIn("Commit Check passed with warnings\n", body) self.assertIn( - f"{group_line('✔', 'passed', 'Pull request: passed')}
\n" - f"{group_line('⚠', 'warned', 'Branch: 1 warning')}
\n" + f"{group_line('✔', 'passed', 'Pull request: passed')}
" + f"{group_line('⚠', 'warned', 'Branch: 1 warning')}
" f"{group_line('⊘', 'skipped', 'Author: skipped')}\n", body, )