"""round-title: print the opening of a round commit's title, counted from the round's report.""" import pathlib from git_cli.git_repo import branch_titles, top from failure import Failure from review_rules.review_folder import findings_in, review_folder, standing_report from review_rules.round_titles import round_prefix from project_config.main import title_templates from larv_review.reviewer_header import unanswered_round def round_title(default: str, pass_: str, home: pathlib.Path) -> str | Failure: """The title prefix of pass_'s unanswered round, counted from that round's report in the chunk's review folder.""" titles = branch_titles(default) if isinstance(titles, Failure): return titles templates = title_templates(None, home) if isinstance(templates, Failure): return templates round_ = unanswered_round([templates.summary(title) for title in titles], pass_) if isinstance(round_, Failure): return round_ worktree = top() if isinstance(worktree, Failure): return worktree findings = findings_in(standing_report(pathlib.Path(review_folder(str(home), worktree)), pass_, round_)) return findings if isinstance(findings, Failure) else round_prefix(pass_, round_, findings)