Answer principles round 1: 0 🔴, 2 🟡; test every guard, name a non-UTF-8 file name as an exit 1, fail on a malformed rev-parse

This commit is contained in:
2026-10-21 20:05:36 +02:00
parent 3fc6790bee
commit 3ae89c3acf
4 changed files with 44 additions and 18 deletions
+6 -5
View File
@@ -25,11 +25,11 @@ single tracked file.
Below the table it names:
- each run it skipped because its commit is not in the checkout;
- each run it could not score because its places name no measured unit, or every one;
- each file left out of its run because git cannot show it, such as a file that is not UTF-8, or
it does not parse on this Python.
- each file left out of its run because git's output for it is not UTF-8, because git cannot show
it, or because it does not parse on this Python.
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the history
cannot be read, or no scoring run could be scored.
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, a tracked
file's name is not UTF-8, the history cannot be read, or no scoring run could be scored.
"""
import pathlib
import statistics
@@ -110,7 +110,8 @@ def noted(notes: list[str]) -> str:
def run_scores(run: Entry, top: str) -> tuple[RunScores | None, list[str]] | Failure:
"""The run's scores, and why each file git cannot show or that does not parse was left out."""
"""The run's scores, and why each file left out was: git could not show it as UTF-8, or it does not parse."""
# A tracked name that is not UTF-8 fails the run rather than reading with its bytes replaced: every tool reads git's output through git_repo.git's one contract.
listed = git("ls-tree", "-r", "-z", "--name-only", run.commit, cwd=top)
if isinstance(listed, Failure):
return listed