Test adding color to diff; fix newline in error report

This commit is contained in:
Zanie
2023-10-26 17:11:18 -05:00
parent 06f71f5235
commit 087d9c705e
2 changed files with 15 additions and 3 deletions

View File

@@ -15,7 +15,11 @@ from subprocess import PIPE
from typing import TYPE_CHECKING, Iterable, Iterator, Self, Sequence
from ruff_ecosystem import logger
from ruff_ecosystem.markdown import markdown_details, markdown_project_section
from ruff_ecosystem.markdown import (
markdown_details,
markdown_project_section,
markdown_plus_minus,
)
from ruff_ecosystem.types import (
Comparison,
Diff,
@@ -72,7 +76,11 @@ def markdown_check_result(result: Result) -> str:
return "\u2705 ecosystem check detected no linter changes."
# Summarize the total changes
changes = f"+{total_added} -{total_removed} violations, +{total_added_fixes} -{total_removed_fixes} fixes in {len(result.completed)} projects"
changes = (
f"{markdown_plus_minus(total_added, total_removed)} violations, "
f"{markdown_plus_minus(total_added_fixes, total_removed_fixes)} fixes"
f"in {len(result.completed)} projects"
)
if error_count:
s = "s" if error_count != 1 else ""
changes += f"; {error_count} project error{s}"
@@ -186,7 +194,7 @@ def markdown_check_result(result: Result) -> str:
lines.extend(
markdown_project_section(
title="error",
content=f"```\n{error}\n```",
content=f"```\n{error}```",
options=project.check_options,
project=project,
)

View File

@@ -17,6 +17,10 @@ def markdown_project_section(
)
def markdown_plus_minus(added: int, removed: int) -> str:
return f'<span style="color: green;">+{added}</span> <span style="color: red;">-{removed}</span>'
def markdown_details(summary: str, preface: str, content: str | list[str]):
lines = []
lines.append(f"<details><summary>{summary}</summary>")