Let a project's config name a working branch per epic that chunks branch off and merge into
CI / tests (pull_request) Successful in 5m4s

This commit is contained in:
Lilleman
2026-11-20 19:32:59 +01:00
parent 9531e5c337
commit 72a4d346d7
33 changed files with 991 additions and 56 deletions
+15
View File
@@ -50,6 +50,9 @@ LANGUAGE = "language"
COMMIT_TITLE = "commit-title"
PULL_REQUEST_TITLE = "pull-request-title"
BRANCH = "branch"
# Two optional settings. `epic-branch` names the working branch that an epic's chunks branch off and merge into, `{epic}` standing for the epic's key (docs/decisions.md → `epic-branch: an epic's chunks branch off and merge into a working branch …`). `review-request-comment` is the comment `chunk-pr` posts on a pull request into that branch, to ask a reviewer that reviews only pull requests into the default branch. Three readers, seated as the human who writes the config, a chunk's worker and one of a client's team, picked both spellings from four candidates each, 3-0: `merge-branch` and `working-branch` read as the chunk's own branch, and `base-branch` as replacing the default branch for the whole repo.
EPIC_BRANCH = "epic-branch"
REVIEW_REQUEST_COMMENT = "review-request-comment"
# An optional path setting: main's help says what it places.
TOUCH_PREDICTIONS = "touch-predictions"
# An optional setting: a list of paths, each spelt as SPELLING says, to the files that hold the team's own coding conventions, which each reviewer agent larv-review launches reads. Three readers, seated as the human who writes a client's config, picked the spelling 2-1 from four candidates, over a bare `conventions`, which they confused with `principles` and `working-rules`.
@@ -141,6 +144,10 @@ class ProjectConfig:
commit_title: str = templates.TITLE
pull_request_title: str = templates.TITLE
branch: str = templates.BRANCH
# The config's `epic-branch` template, or None where it sets none.
epic_branch: str | None = None
# The config's `review-request-comment`, or None where it sets none.
review_request_comment: str | None = None
# The config's `coding-conventions`, in its order; empty where it sets none.
coding_conventions: tuple[pathlib.Path, ...] = ()
# The epic whose child issues are the plan, where the config's `plan` names one.
@@ -237,6 +244,7 @@ def load(top: pathlib.Path, main: pathlib.Path, home: pathlib.Path) -> ProjectCo
*(f"`{name}` is set, so `plan` must name a Jira epic" for name in JIRA_PLAN_ONLY if name in values and not epics["plan"]),
*(f"`plan` names a Jira epic, so `{name}` must be set, as `project-config --help` shows" for name in JIRA_SCORE if epics["plan"] and name not in values),
*finish_faults(values),
*([f"`{REVIEW_REQUEST_COMMENT}` is set, so `{EPIC_BRANCH}` must be set: the comment goes on pull requests into that branch"] if REVIEW_REQUEST_COMMENT in values and EPIC_BRANCH not in values else []),
*([f"`{JIRA_SCORE_FORMULA}` is {formula!r}: {fault}"] if JIRA_SCORE_FORMULA in values and (fault := formula_fault(formula)) else []),
*([f"`{JIRA_SCORE_BAR}` is {bar!r}, not a bare number, such as `{JIRA_SCORE_BAR} = 1`"] if JIRA_SCORE_BAR in values and bar_of(bar) is None else []),
]
@@ -359,6 +367,11 @@ def language_fault(value: object) -> str | None:
return None if named else 'not a language\'s English name in words of letters, such as "Swedish" or "Brazilian Portuguese"'
def comment_fault(value: object) -> str | None:
"""Why value is no comment to post on a pull request; None where it is one."""
return None if isinstance(value, str) and value.strip() and "\n" not in value else 'not one line of text, such as "@coderabbitai review"'
# Each one-value setting, in the order `project-config` lists them.
SCALARS = (
Scalar(WAIT_FOR_APPROVAL, "wait_for_approval", switch, lambda on: "true" if on else "false"),
@@ -371,6 +384,8 @@ SCALARS = (
Scalar(COMMIT_TITLE, "commit_title", text_read(templates.title_fault)),
Scalar(PULL_REQUEST_TITLE, "pull_request_title", text_read(templates.title_fault)),
Scalar(BRANCH, "branch", text_read(templates.branch_fault)),
Scalar(EPIC_BRANCH, "epic_branch", text_read(templates.epic_branch_fault)),
Scalar(REVIEW_REQUEST_COMMENT, "review_request_comment", text_read(comment_fault)),
Scalar(JIRA_FINDING_TYPE, "jira_finding_type", text_read(type_fault)),
)
OPTIONAL = tuple(sorted({CODING_CONVENTIONS, ENV_FILE, TOUCH_PREDICTIONS, *JIRA_PLAN_ONLY, *(scalar.name for scalar in SCALARS)}))