fix: stabilize consistency make wrappers

This commit is contained in:
2026-06-07 19:49:17 +02:00
parent 54b867192d
commit e9e9168921
4 changed files with 169 additions and 37 deletions

View File

@@ -33,9 +33,13 @@ Usage:
python scripts/consistency_check.py --here [PATH] [--fix] [--no-writeback] [--json] [--api-base URL]
Exit codes:
0 — ok (no FAILs; only WARNs/INFOs)
0 — clean (no FAILs or WARNs; INFOs are allowed)
1 — one or more FAILs present
2 — warn-only (no FAILs, but WARNs present)
2 — warnings-only strict CLI result (no FAILs, but WARNs present)
Agent/operator Make wrappers normalize exit code 2 to shell success while
preserving visible warning output. Use the direct script when a machine caller
needs to distinguish clean from warnings-only.
"""
from __future__ import annotations
@@ -2161,6 +2165,15 @@ def report_to_dict(report: ConsistencyReport) -> dict:
}
def consistency_exit_code(reports: list[ConsistencyReport], *, remote_all: bool = False) -> int:
"""Return the strict CLI exit code for consistency reports."""
any_fail = any(r.failures for r in reports)
any_warn = any(r.warnings for r in reports)
if remote_all and not any_fail:
return 0
return 1 if any_fail else 2 if any_warn else 0
# ---------------------------------------------------------------------------
# CLI entry point
# ---------------------------------------------------------------------------
@@ -2329,11 +2342,7 @@ def main() -> None:
print(render_text(report))
print()
any_fail = any(r.failures for r in reports)
any_warn = any(r.warnings for r in reports)
if args.remote and args.all and not any_fail:
sys.exit(0)
sys.exit(1 if any_fail else 2 if any_warn else 0)
sys.exit(consistency_exit_code(reports, remote_all=args.remote and args.all))
if __name__ == "__main__":