Answer architecture round 1: move the base fallback, heading check and seat names into the pure modules, move legacy scores through record-scoring, and read origin as last fetched when a fetch fails
This commit is contained in:
+23
-27
@@ -15,7 +15,7 @@ of HEAD and the default branch.
|
||||
|
||||
round-count prints, for each pass, the highest <n> among this branch's commit titles opening
|
||||
`Answer <pass> round <n>:`, counting commits the default branch does not hold, and marks a pass at
|
||||
the cap of 3 rounds, and a name in such a title that is no pass.
|
||||
the cap of {cap} rounds, and a name in such a title that is no pass.
|
||||
|
||||
needs-scoring-run prints why the chunk shipping the given todo.md item IDs takes a scoring run, or
|
||||
`No scoring run due.` It is due when the chunk ships an item whose tagline names the comprehension
|
||||
@@ -43,13 +43,14 @@ appends nothing and says to add the maintainability senior's and Junior A's line
|
||||
ruling is the vote that leads each other vote by two or more, else same, and it appends the ruling.
|
||||
|
||||
record-scoring takes Junior A's, Mid A's, the maintainability senior's and the inherited
|
||||
architect's lines in that order, each `Navigation <n>, Locality <n>, Shape <n>, Self-sufficiency
|
||||
<n>, Overall <n>`, each score from 1 to 10 and the overall at most 1 above the seat's lowest
|
||||
dimension. A first line names no `, against`. It appends the seats' scores and their means, rounded
|
||||
half up to two decimals, and prints the means and each one under the floor of 7.0.
|
||||
architect's lines in that order, or a `Mean:` line alone for a run moved from a decision entry.
|
||||
Each line is `Navigation <n>, Locality <n>, Shape <n>, Self-sufficiency <n>, Overall <n>`, each
|
||||
score from 1 to 10 and the overall at most 1 above the line's lowest dimension. A first line names no `, against`. It appends the seats' scores and their means, rounded
|
||||
half up to two decimals, and prints the means and each one under the floor of {floor}.
|
||||
|
||||
Each record is appended to the history, created when missing, under a heading of the current UTC
|
||||
time and the seats file's first line.
|
||||
time and the seats file's first line, or of that line alone when it opens with a date. Each commit
|
||||
the line names must be in the checkout.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that
|
||||
breaks the shape above, or when git cannot start, finds no checkout or no default branch, or the
|
||||
@@ -60,9 +61,9 @@ import sys
|
||||
import time
|
||||
import typing
|
||||
|
||||
from larv_review.history import appended, HEADING, heading, ruling_entry, scoring_entry
|
||||
from larv_review.rules import CAP, first_ruling, means, measured_commit, PASSES, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
|
||||
from larv_review.git import default_branch, file_at, git, HISTORY, history_changes, landed_since_release, top
|
||||
from larv_review.history import appended, heading, ruling_entry, scoring_entry
|
||||
from larv_review.rules import base, CAP, FLOOR, means, PASSES, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
|
||||
from larv_review.git import commit_exists, default_branch, file_at, git, HISTORY, history_changes, landed_since_release, top
|
||||
from larv_review.seats import DIMENSIONS, report, scores
|
||||
from failure import Failure
|
||||
from file_writes import replace_file
|
||||
@@ -72,7 +73,7 @@ USAGE = "usage: larv-review ruling-base | round-count | needs-scoring-run <item
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if argv in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
print(__doc__.strip().format(cap=CAP, floor=FLOOR))
|
||||
return 0
|
||||
command, *given = argv or [""]
|
||||
if command in ("ruling-base", "round-count") and not given:
|
||||
@@ -99,19 +100,13 @@ def ruling_base(default: str) -> Failure | None:
|
||||
changes = history_changes(default)
|
||||
if isinstance(changes, Failure):
|
||||
return changes
|
||||
if found := measured_commit(changes):
|
||||
print(f"{found}\nThe newest merged change on {default} that adds a scoring run to {HISTORY}, or whose last added paired ruling is better.")
|
||||
return None
|
||||
history = file_at(default, HISTORY)
|
||||
if isinstance(history, Failure):
|
||||
return history
|
||||
if (first := first_ruling(history)) and first.against:
|
||||
print(f"{first.against}\nNo merged change on {default} adds a scoring run or a better ruling; the base its first paired ruling names.")
|
||||
return None
|
||||
merge_base = git("merge-base", "HEAD", default)
|
||||
if isinstance(merge_base, Failure):
|
||||
return merge_base
|
||||
print(f"{merge_base.strip()}\nNo merged change on {default} adds a scoring run or a paired ruling; the merge base of HEAD and {default}.")
|
||||
print("\n".join(base(changes, history, merge_base.strip(), default)))
|
||||
return None
|
||||
|
||||
|
||||
@@ -133,22 +128,20 @@ def needs_scoring_run(default: str, ids: list[int]) -> Failure | None:
|
||||
return before
|
||||
try:
|
||||
after = pathlib.Path(checkout, "todo.md").read_text(encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
after = ""
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read todo.md: {failure}")
|
||||
planned = plan_items(before)
|
||||
if isinstance(planned, Failure):
|
||||
return planned
|
||||
return Failure(f"{default}'s todo.md: {planned.reason}")
|
||||
chunk = plan_items(after)
|
||||
if isinstance(chunk, Failure):
|
||||
return chunk
|
||||
if unknown := sorted(set(ids) - {item.id for item in planned + chunk}):
|
||||
return Failure(f"neither {default}'s todo.md nor the checkout's holds item {', '.join(map(str, unknown))}")
|
||||
return Failure(f"the checkout's todo.md: {chunk.reason}")
|
||||
landed = landed_since_release(default)
|
||||
if isinstance(landed, Failure):
|
||||
return landed
|
||||
reasons = scoring_run_due(planned, chunk, ids, landed)
|
||||
if isinstance(reasons, Failure):
|
||||
return reasons
|
||||
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
|
||||
return None
|
||||
|
||||
@@ -160,9 +153,12 @@ def record(seats_file: pathlib.Path, paired: bool) -> Failure | None:
|
||||
return Failure(f"could not read {seats_file}: {failure}")
|
||||
if isinstance(given, Failure):
|
||||
return given
|
||||
title = heading(time.time(), given.read)
|
||||
if not (named := HEADING.match(title)) or bool(named.group(4)) != paired:
|
||||
return Failure(f"the seats file's first line is not `<PR or branch> at <commit>{', against <base>' if paired else ''}`: {given.read}")
|
||||
named = heading(time.time(), given.read, paired)
|
||||
if isinstance(named, Failure):
|
||||
return named
|
||||
title = named.group(0)
|
||||
if unknown := [commit for commit in named.group(3, 4) if commit and not commit_exists(commit)]:
|
||||
return Failure(f"the seats file names {', '.join(unknown)}, which is no commit in this checkout")
|
||||
if paired:
|
||||
counted = votes(given.seats)
|
||||
if isinstance(counted, Failure):
|
||||
@@ -179,7 +175,7 @@ def record(seats_file: pathlib.Path, paired: bool) -> Failure | None:
|
||||
return found
|
||||
mean = means(found)
|
||||
under = under_floor(mean)
|
||||
print(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, mean))}. {'Under the floor of 7.0: ' + ', '.join(under) if under else 'None under the floor of 7.0'}.")
|
||||
print(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, mean))}. {f'Under the floor of {FLOOR}: ' + ', '.join(under) if under else f'None under the floor of {FLOOR}'}.")
|
||||
return append(scoring_entry(title, given.seats, found, [str(value) for value in mean]))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user