Answer stability round 1: 0 🔴, 2 🟡 (0 misread); read non-ASCII paths with numstat -z, and say on stderr when a chunk's details cannot be read
This commit is contained in:
@@ -12,10 +12,10 @@ from release_plan.named_code import named_files
|
||||
ENOUGH = 10
|
||||
|
||||
|
||||
# An item's size in lines, not an S: no published scale maps lines to S, and the report's S medians already set the S guessed beside the lines changed.
|
||||
# A size in files and lines, not an S, since no published scale maps lines to S. The report's S medians show which S was guessed for how many lines changed.
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class NamedCode:
|
||||
"""The tracked files an item's tagline and detail name, folders by the files they hold, as the chunk that shipped it found them: how many, and their lines, a binary file holding none. They bound what the chunk's change could touch."""
|
||||
"""How many tracked files an item's tagline and detail name, and their lines, as they stood before the chunk that shipped it. A named folder counts the files it holds. A binary file counts no lines."""
|
||||
files: int
|
||||
lines: int
|
||||
|
||||
@@ -37,8 +37,6 @@ class Result:
|
||||
named: NamedCode | None
|
||||
|
||||
|
||||
|
||||
|
||||
# A measure's name and how to read it from a Result, None where the chunk did not record it.
|
||||
Measure = tuple[str, typing.Callable[[Result], int | None]]
|
||||
# The scores whose median result the report gives at each guessed value.
|
||||
@@ -63,13 +61,13 @@ def results_of(chunk: BranchChunk, numstat: str, details: dict[int, str], tree:
|
||||
|
||||
|
||||
def item_text(item: Item, details: dict[int, str]) -> str:
|
||||
"""The tagline and detail, where the item names the files it changes."""
|
||||
"""The text that may name files: the item's tagline and its detail."""
|
||||
return f"{item.tagline}\n{details.get(item.id, '')}"
|
||||
|
||||
|
||||
def file_lines(numstat: str) -> dict[str, int]:
|
||||
"""Each file's lines from `git diff --numstat` against the empty tree, which counts every line as added; git counts a binary file's lines as "-", so it holds none."""
|
||||
rows = [row.split("\t", 2) for row in numstat.splitlines()]
|
||||
"""Each file's lines from `git diff --numstat -z` against the empty tree, which counts every line as added. Git prints "-" for a binary file's lines, so that file counts 0 lines."""
|
||||
rows = [row.split("\t", 2) for row in numstat.split("\0")]
|
||||
return {row[2]: int(row[0]) if row[0].isdigit() else 0 for row in rows if len(row) == 3}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user