fix: render detection in the report text

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 16:43:46 +01:00
1 parent beefb32cc8
commit 2025a71cb9
4 files changed
+53 -29

No files matched your search

+1 -13
View File
@@ -248,28 +248,16 @@ def detect_upstream_changes(
report.new_hashes = new_hashes
def _print_detection(report: ProfileReport) -> None:
if report.detection_skipped:
print(f" extras skipped: {report.detection_skipped}")
for item in report.new_files or ():
print(f" new file: {item['path']}:{item['line']} {item['name']}")
for path, elided in report.new_files_elided.items():
print(f" new file: {path}: {elided} further matches not shown")
for item in report.new_hashes or ():
print(f" new {item['kind']}: {item['path']} {item['value']}")
def print_extras(
args: argparse.Namespace, profile: dict, report: ProfileReport
) -> None:
"""Optional per-profile sections beyond the ref report.
"""--full-diff and --tree-diff, read from the forge after the ref report.
The ref report mutes a forge that refuses, but the extras read the same
forge again, so a refusal here is reported on the profile's own line
instead of ending a pass over every profile. A quota signal still
ends the profile.
"""
_print_detection(report)
if not (args.full_diff or args.tree_diff) or not report.head:
return
repo = select_repo(profile)
+5 -7
View File
@@ -95,17 +95,15 @@ def refuse_flag_combinations(args: argparse.Namespace) -> None:
("--triage", args.triage),
) if on
]
# The version check lives on the report, so the outputs built from the
# report (text, --json, --markdown) carry it. A URL list and a ranking
# do not. Detection lives on the report too, and --json carries it for
# check_freshness. The markdown table has no column for it.
# The version check and detection live on the report, so the outputs
# built from the report (text, --json, --markdown) carry them. A URL
# list and a ranking do not.
lists_only = args.fetch_plan or args.triage
off_json = lists_only or args.markdown
extras = [
flag for flag, on in (
("--check-version", args.check_version and lists_only),
("--detect-new-files", args.detect_new_files and off_json),
("--watch-hashes", args.watch_hashes and off_json),
("--detect-new-files", args.detect_new_files and lists_only),
("--watch-hashes", args.watch_hashes and lists_only),
("--full-diff", args.full_diff),
("--tree-diff", args.tree_diff),
) if on
+23 -2
View File
@@ -254,13 +254,34 @@ def _report_body(report: ProfileReport, changed_only: bool) -> list[str]:
return lines
def _detection_lines(report: ProfileReport) -> list[str]:
"""--detect-new-files and --watch-hashes findings of one report."""
lines = []
if report.detection_skipped:
lines.append(f" extras skipped: {report.detection_skipped}")
lines.extend(
f" new file: {item['path']}:{item['line']} {item['name']}"
for item in report.new_files or ()
)
lines.extend(
f" new file: {path}: {elided} further matches not shown"
for path, elided in report.new_files_elided.items()
)
lines.extend(
f" new {item['kind']}: {item['path']} {item['value']}"
for item in report.new_hashes or ()
)
return lines
def format_report(report: ProfileReport, changed_only: bool = False) -> str:
"""Human-readable report for one profile."""
lines = _report_header(report)
if report.skipped:
lines.append(f" skipped: {report.skipped}")
return "\n".join(lines)
return "\n".join(lines + _report_body(report, changed_only))
else:
lines.extend(_report_body(report, changed_only))
return "\n".join(lines + _detection_lines(report))
def report_to_dict(report: ProfileReport) -> dict: