Skip to content

Commit 2c6b534

Browse files
authored
Update ecosystem check headers to show unchanged project count (astral-sh#9157)
Instead of displaying the total completed project count in the "changed" section of a header, we now separately calculated the changed and unchanged count to make the header message nice and clear. e.g. > ℹ️ ecosystem check **detected format changes**. (+1772 -1859 lines in 239 files in 26 projects; 6 project errors; 9 projects unchanged) and > ℹ️ ecosystem check **detected linter changes**. (+4598 -5023 violations, +0 -40 fixes in 13 projects; 4 project errors; 24 projects unchanged) Previously, it would have included the unchanged count in the first project count.
1 parent 6ecf844 commit 2c6b534

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎python/ruff-ecosystem/ruff_ecosystem/check.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def markdown_check_result(result: Result) -> str:
5252
"""
5353
Render a `ruff check` ecosystem check result as markdown.
5454
"""
55+
projects_with_changes = 0
56+
5557
# Calculate the total number of rule changes
5658
all_rule_changes = RuleChanges()
5759
project_diffs = {
@@ -63,6 +65,9 @@ def markdown_check_result(result: Result) -> str:
6365
project_rule_changes[project] = changes = RuleChanges.from_diff(diff)
6466
all_rule_changes.update(changes)
6567

68+
if diff:
69+
projects_with_changes += 1
70+
6671
lines: list[str] = []
6772
total_removed = all_rule_changes.total_removed_violations()
6873
total_added = all_rule_changes.total_added_violations()
@@ -88,11 +93,17 @@ def markdown_check_result(result: Result) -> str:
8893
change_summary = (
8994
f"{markdown_plus_minus(total_added, total_removed)} violations, "
9095
f"{markdown_plus_minus(total_added_fixes, total_removed_fixes)} fixes "
91-
f"in {len(result.completed)} projects"
96+
f"in {projects_with_changes} projects"
9297
)
9398
if error_count:
9499
s = "s" if error_count != 1 else ""
95100
change_summary += f"; {error_count} project error{s}"
101+
102+
unchanged_projects = len(result.completed) - projects_with_changes
103+
if unchanged_projects:
104+
s = "s" if unchanged_projects != 1 else ""
105+
change_summary += f"; {unchanged_projects} project{s} unchanged"
106+
96107
lines.append(
97108
f"\u2139\ufe0f ecosystem check **detected linter changes**. ({change_summary})"
98109
)

‎python/ruff-ecosystem/ruff_ecosystem/format.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def markdown_format_result(result: Result) -> str:
2828
lines: list[str] = []
2929
total_lines_removed = total_lines_added = 0
3030
total_files_modified = 0
31+
projects_with_changes = 0
3132
error_count = len(result.errored)
3233
patch_sets: list[PatchSet] = []
3334

@@ -39,6 +40,9 @@ def markdown_format_result(result: Result) -> str:
3940
patch_sets.append(patch_set)
4041
total_files_modified += len(patch_set.modified_files)
4142

43+
if comparison.diff:
44+
projects_with_changes += 1
45+
4246
if total_lines_removed == 0 and total_lines_added == 0 and error_count == 0:
4347
return "\u2705 ecosystem check detected no format changes."
4448

@@ -51,11 +55,21 @@ def markdown_format_result(result: Result) -> str:
5155
)
5256
else:
5357
s = "s" if total_files_modified != 1 else ""
54-
changes = f"+{total_lines_added} -{total_lines_removed} lines in {total_files_modified} file{s} in {len(result.completed)} projects"
58+
changes = (
59+
f"+{total_lines_added} -{total_lines_removed} lines "
60+
f"in {total_files_modified} file{s} in "
61+
f"{projects_with_changes} projects"
62+
)
63+
5564
if error_count:
5665
s = "s" if error_count != 1 else ""
5766
changes += f"; {error_count} project error{s}"
5867

68+
unchanged_projects = len(result.completed) - projects_with_changes
69+
if unchanged_projects:
70+
s = "s" if unchanged_projects != 1 else ""
71+
changes += f"; {unchanged_projects} project{s} unchanged"
72+
5973
lines.append(
6074
f"\u2139\ufe0f ecosystem check **detected format changes**. ({changes})"
6175
)

0 commit comments

Comments
 (0)