Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion repoReleaseAudit/repo_release_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions repoReleaseAudit/tests/test_repo_release_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Loading