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
4 changes: 2 additions & 2 deletions src/local_coding_slm/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def git_tracked_text_files(root: Path) -> list[tuple[str, str]] | None:
try:
text = path.read_text(encoding="utf-8")
except (OSError, UnicodeDecodeError):
continue
return None
out.append((str(path.relative_to(root)), text))
return out

Expand All @@ -400,7 +400,7 @@ def _committed_ip_result(
return classify_tracked_ipv4(list(tracked))
files = git_tracked_text_files(repo)
if files is None:
return CheckResult("committed_ips", "fail", "could not list tracked files")
return CheckResult("committed_ips", "fail", "could not read tracked files")
return classify_tracked_ipv4(files)


Expand Down
28 changes: 27 additions & 1 deletion tests/test_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,38 @@ def test_git_ls_files_failure_fails_closed(self) -> None:
results = run_checks(**safe)
ips = next(item for item in results if item.name == "committed_ips")
self.assertEqual(ips.status, "fail")
self.assertIn("could not list", ips.message)
self.assertIn("could not read", ips.message)
with patch("local_coding_slm.safety.subprocess.run", side_effect=OSError("git missing")):
raised = run_checks(**safe)
missing = next(item for item in raised if item.name == "committed_ips")
self.assertEqual(missing.status, "fail")

def test_unreadable_tracked_file_fails_closed(self) -> None:
"""A tracked text file that cannot be decoded is not an empty tree."""
import subprocess
import tempfile
from pathlib import Path

with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
(root / "notes.md").write_bytes(b"see 8.8.8.8 \xff\n")
subprocess.run(["git", "init"], cwd=root, check=True, capture_output=True)
subprocess.run(["git", "add", "-A"], cwd=root, check=True, capture_output=True)
results = run_checks(
environ={
"OLLAMA_BASE_URL": "http://127.0.0.1:11434",
"OLLAMA_FAST_MODEL": "qwen3.5:9b",
"OLLAMA_STRONG_MODEL": "devstral-small-2",
},
listen_rows=[("127.0.0.1", 11434)],
env_ignored=True,
env_example_text="OLLAMA_BASE_URL=http://127.0.0.1:11434\n",
root=root,
)
ips = next(item for item in results if item.name == "committed_ips")
self.assertEqual(ips.status, "fail")
self.assertIn("could not read", ips.message)

def test_unofficial_library_tag_fails_run_checks(self) -> None:
results = run_checks(
environ={
Expand Down
Loading