Have larv-review round-title print a round commit's counts from its report, and rule-hook refuse a title that differs
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
||||
import pathlib
|
||||
|
||||
from failure import Failure
|
||||
from review_rules.round_titles import Findings, reported
|
||||
|
||||
# Why here: docs/decisions.md → `review: each reviewer under agents/ writes its full report into the chunk's review folder`.
|
||||
REPORTS = ".local/state/larv-review"
|
||||
@@ -24,3 +25,29 @@ def made_review_folder(worktree: str, home: pathlib.Path) -> pathlib.Path | Fail
|
||||
except OSError as failure:
|
||||
return Failure(f"could not make the review folder {folder}: {failure}")
|
||||
return folder
|
||||
|
||||
|
||||
def round_report(folder: pathlib.Path, pass_: str, round_: int) -> pathlib.Path:
|
||||
"""The report of pass_'s round round_ in the review folder, which asks for the rerun one rung up where there is one."""
|
||||
return folder / f"{pass_}-round-{round_}.md"
|
||||
|
||||
|
||||
def rerun_report(asked: pathlib.Path) -> pathlib.Path:
|
||||
"""The report of the rerun one rung up that the report asked asks for, which stands in its place."""
|
||||
return asked.with_name(asked.stem + "-rerun.md")
|
||||
|
||||
|
||||
def standing_report(folder: pathlib.Path, pass_: str, round_: int) -> pathlib.Path:
|
||||
"""The report that stands for pass_'s round round_ in the review folder: the rerun's where there is one, else the round's."""
|
||||
asked = round_report(folder, pass_, round_)
|
||||
return rerun_report(asked) if rerun_report(asked).exists() else asked
|
||||
|
||||
|
||||
def findings_in(report: pathlib.Path) -> Findings | Failure:
|
||||
"""The findings a round's report gives, as round_titles.reported counts them."""
|
||||
try:
|
||||
return reported(report.read_text(encoding="utf-8"))
|
||||
except FileNotFoundError:
|
||||
return Failure(f"no report at {report}")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {report}: {failure}")
|
||||
|
||||
Reference in New Issue
Block a user