From 9150c5c0530c320710bdaaad4c8d651475844ac8 Mon Sep 17 00:00:00 2001 From: whning Date: Sat, 31 Oct 2026 20:23:06 +0800 Subject: [PATCH] Report oversized text omitted from release scans --- repoReleaseAudit/repo_release_audit.py | 5 ++++- repoReleaseAudit/tests/test_repo_release_audit.py | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/repoReleaseAudit/repo_release_audit.py b/repoReleaseAudit/repo_release_audit.py index 0a54dc5..89766ea 100644 --- a/repoReleaseAudit/repo_release_audit.py +++ b/repoReleaseAudit/repo_release_audit.py @@ -77,7 +77,10 @@ def is_text_candidate(path: Path) -> bool: def scan_text(path: Path, relative: str, findings: list[Finding]) -> None: - if not is_text_candidate(path) or path.stat().st_size > 2 * 1024 * 1024: + if not is_text_candidate(path): + return + if path.stat().st_size > 2 * 1024 * 1024: + findings.append(Finding("error", "text-too-large-to-scan", relative)) return try: text = path.read_text(encoding="utf-8") diff --git a/repoReleaseAudit/tests/test_repo_release_audit.py b/repoReleaseAudit/tests/test_repo_release_audit.py index 04a992f..93a93b0 100644 --- a/repoReleaseAudit/tests/test_repo_release_audit.py +++ b/repoReleaseAudit/tests/test_repo_release_audit.py @@ -184,3 +184,12 @@ def run_git_with_failed_status(root: Path, *args: str): assert result["summary"]["dirty"] is True assert any(item["code"] == "git-status-failed" and item["level"] == "error" for item in result["findings"]) assert "private git error" not in audit_module.render_text(result) + + +def test_oversized_text_is_reported_as_not_scanned(tmp_path: Path) -> None: + root = tmp_path / "repo" + init_repo(root) + (root / "large.txt").write_bytes(b"x" * (2 * 1024 * 1024 + 1)) + git(root, "add", "large.txt") + result = audit_module.audit(root) + assert any(item["code"] == "text-too-large-to-scan" and item["path"] == "large.txt" and item["level"] == "error" for item in result["findings"])