Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""reviewer-header: write the branch diff, the places and the plan into the chunk's review folder, and print the header of a reviewer's prompt."""
|
||||
import dataclasses
|
||||
from collections.abc import Mapping
|
||||
import pathlib
|
||||
|
||||
from git_cli.git_repo import branch_titles, git, top
|
||||
@@ -80,18 +81,18 @@ def unanswered_round(titles: list[str], pass_: str) -> int | Failure:
|
||||
return done + 1
|
||||
|
||||
|
||||
def branch_summaries(default: str, home: pathlib.Path) -> list[str] | Failure:
|
||||
def branch_summaries(default: str, home: pathlib.Path, env: Mapping[str, str]) -> list[str] | Failure:
|
||||
"""The branch's commit titles since default, each read as its summary in the project's title templates, so round titles count under any template. rule-hook's round-cap reads them its own way: guarded, and counting zero rounds where git fails."""
|
||||
titles = branch_titles(default)
|
||||
if isinstance(titles, Failure):
|
||||
return titles
|
||||
templates = title_templates(None, home)
|
||||
templates = title_templates(None, home, env)
|
||||
return templates if isinstance(templates, Failure) else [templates.summary(title) for title in titles]
|
||||
|
||||
|
||||
def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -> str | Failure:
|
||||
def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path, env: Mapping[str, str]) -> str | Failure:
|
||||
"""Writes the branch diff, the places and the plan's listing into the review folder, and returns the header that launches pass_'s reviewer in the pass's unanswered round, or its relaunch one rung up where rerun."""
|
||||
summaries = branch_summaries(default, home)
|
||||
summaries = branch_summaries(default, home, env)
|
||||
round_ = summaries if isinstance(summaries, Failure) else unanswered_round(summaries, pass_)
|
||||
if isinstance(round_, Failure):
|
||||
return round_
|
||||
@@ -100,10 +101,10 @@ def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -
|
||||
if failed is not None:
|
||||
return failed
|
||||
worktree, branch, head, base = (str(answer).strip() for answer in found)
|
||||
folder = made_review_folder(worktree, home)
|
||||
folder = made_review_folder(worktree, home, env)
|
||||
if isinstance(folder, Failure):
|
||||
return folder
|
||||
config = located(None, home)
|
||||
config = located(None, home, env)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
principles, standards = config.paths["principles"], config.paths["standards"]
|
||||
@@ -125,18 +126,18 @@ def reviewer_header(default: str, pass_: str, rerun: bool, home: pathlib.Path) -
|
||||
launch = Launch(pass_, round_, rerun, pull_named(worktree, branch), worktree, branch, base, default, folder, folder / f"branch-{head}.diff", principles, standards, goals, folder / "plan.md", starts_bare(next((agent for name, agent in REVIEWERS.items() if name == pass_), ""), home), config.paths["working-rules"], decisions, config.language, config.coding_conventions)
|
||||
if rerun and not launch.asked().exists():
|
||||
return Failure(f"no report asked for a rerun of {pass_}'s round {round_}: {launch.asked()} is missing; relaunch before you commit the round's answers")
|
||||
written = write_inputs(launch, base, home, plan_listing(plan_store(config)))
|
||||
written = write_inputs(launch, base, home, env, plan_listing(plan_store(config)))
|
||||
if isinstance(written, Failure):
|
||||
return written
|
||||
return launch.header()
|
||||
|
||||
|
||||
def write_inputs(launch: Launch, base: str, home: pathlib.Path, listing: str) -> Failure | None:
|
||||
def write_inputs(launch: Launch, base: str, home: pathlib.Path, env: Mapping[str, str], listing: str) -> Failure | None:
|
||||
"""Writes the branch diff from base to HEAD, what `larv-review places` prints, and the plan's listing into the review folder."""
|
||||
diff = git("diff", base, "HEAD", errors="replace")
|
||||
if isinstance(diff, Failure):
|
||||
return diff
|
||||
history = history_file(home)
|
||||
history = history_file(home, env)
|
||||
if isinstance(history, Failure):
|
||||
return history
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user