Answer architecture round 1: 4 🔴, 5 🟡 (0 misread); one-way plan packages with a plan core and an Atlassian client, one parse and print of an item's cells, a pure chunk-start decision, a settings table, one plan read and one standing per pick, one config load in chunk-pr, notifier backends in notifier, and the bin regroup filed as item 392
This commit is contained in:
@@ -140,10 +140,12 @@ def commit_breaches(commit: CommitCall, home: pathlib.Path) -> list[Breach]:
|
||||
if isinstance(config, Failure) and not isinstance(config, Unnamed):
|
||||
unread = [Breach("commit-title", f"the project's config cannot be read, so the title is not checked against its template: {config.reason}", commit.directory)]
|
||||
titles = config.titles if isinstance(config, ProjectConfig) else templates.BARE
|
||||
return unread + title_breaches(commit, titles, isinstance(config, ProjectConfig) and on_item_branch(commit.directory, config.branch)) + round_cap_breaches(commit, titles) + todo_breaches(commit.directory, home)
|
||||
# A checkout no config names has no branch template, so no title of its must fit one.
|
||||
branch = checkout_branch(commit.directory) if isinstance(config, ProjectConfig) else None
|
||||
return unread + title_breaches(commit, titles, config.branch if isinstance(config, ProjectConfig) else templates.BRANCH, branch) + round_cap_breaches(commit, titles) + todo_breaches(commit.directory, home)
|
||||
|
||||
|
||||
def on_item_branch(directory: str, template: str) -> bool:
|
||||
"""Whether directory's checkout is on a branch that fits template, the config's `branch`: a plan item's branch, whose commits carry the item's ID. Any other branch, such as a release review's, has no item to give {id}."""
|
||||
def checkout_branch(directory: str) -> str | None:
|
||||
"""The branch directory's checkout is on; None where HEAD is detached or git cannot tell."""
|
||||
branch = guarded_git(directory, "symbolic-ref", "--quiet", "--short", "HEAD")
|
||||
return not isinstance(branch, Failure) and templates.branch_fits(template, branch)
|
||||
return None if isinstance(branch, Failure) else branch.strip()
|
||||
|
||||
@@ -165,15 +165,15 @@ def command_breaches(command: str, simples: list[Simple]) -> list[Breach]:
|
||||
return breaches
|
||||
|
||||
|
||||
def title_breaches(commit: CommitCall, titles: templates.Titles, held: bool) -> list[Breach]:
|
||||
"""The breaches of the commit's message, read through titles, the project's title templates. held is whether the title must fit the commit template: it must on a branch that fits the config's `branch` template."""
|
||||
def title_breaches(commit: CommitCall, titles: templates.Titles, branch_template: str, branch: str | None) -> list[Breach]:
|
||||
"""The breaches of the commit's message, read through titles, the project's title templates. branch is the checkout's branch, None where it has none, and branch_template the config's `branch`: templates.misfits says when the title must fit the commit template."""
|
||||
breaches = []
|
||||
if commit.from_file:
|
||||
breaches.append(Breach("commit-one-line", "pass the message as one -m '<line>', not from a file", commit.directory))
|
||||
elif len(commit.messages) > 1 or any("\n" in message.strip() for message in commit.messages):
|
||||
breaches.append(Breach("commit-one-line", "pass the message as one -m '<line>', with no heredoc, second -m or newline", commit.directory))
|
||||
# A message of several lines breaks commit-one-line above, which says how to fix it.
|
||||
if held and (misfit := [message for message in commit.messages[:1] if "\n" not in message.strip() and not templates.fits(titles.commit, message.strip())]):
|
||||
if misfit := [message for message in commit.messages[:1] if "\n" not in message.strip() and templates.misfits(titles.commit, branch_template, branch, message)]:
|
||||
breaches.append(Breach("commit-title", f"title the commit as the project's config asks, `{titles.commit}`, where {{id}} is the ID of the chunk's first item; `{misfit[0].strip()[:80]}` doesn't fit", commit.directory))
|
||||
if any(lacks_counts(titles.summary(message.strip())) for message in commit.messages):
|
||||
breaches.append(Breach("round-title-counts", f"open the summary after the round's colon with `{COUNTS}`, where <j> is at most <k> + <m>", commit.directory))
|
||||
|
||||
@@ -20,7 +20,7 @@ from rule_hook.main import breaches_of
|
||||
from rule_hook.call import Call, parsed_call
|
||||
from git_cli.git_command import commit_message, CommitCall, commits
|
||||
from project_config.test_project_config import configured, write_config
|
||||
from release_plan.test_ranking import DECISIONS, README, TODO
|
||||
from plan.test_ranking import DECISIONS, README, TODO
|
||||
from rule_hook.git import guarded_git
|
||||
from test_env import isolated_env
|
||||
from rule_hook.override_log import LogLine, parsed_entry, this_chunks
|
||||
@@ -44,7 +44,7 @@ def committed(command: str, cwd: str = "/r") -> list[CommitCall]:
|
||||
def breaches(command: str, titles: Titles = BARE, held: bool = False) -> list[Breach]:
|
||||
"""The command's breaches and those of each commit's title, read through titles; held is whether the title must fit the commit template."""
|
||||
simples = simple_commands(command, "/r", "/h")
|
||||
return command_breaches(command, simples) + [breach for commit in commits(simples, "/h") for breach in title_breaches(commit, titles, held)]
|
||||
return command_breaches(command, simples) + [breach for commit in commits(simples, "/h") for breach in title_breaches(commit, titles, "item-{id}", "item-7" if held else "main")]
|
||||
|
||||
|
||||
def checked(command: str) -> list[str]:
|
||||
|
||||
@@ -6,11 +6,11 @@ import sys
|
||||
|
||||
from rule_hook.rules import Breach
|
||||
from failure import Failure
|
||||
from plan_store.stores import file_plan
|
||||
from git_cli.git_repo import git
|
||||
from rule_hook.git import guarded_git
|
||||
from project_config.settings import held, ProjectConfig
|
||||
from project_config.main import located
|
||||
from release_plan import plan_file
|
||||
|
||||
|
||||
# The checkout this hook runs from: bin/rule_hook/ sits two folders below it.
|
||||
@@ -60,7 +60,7 @@ def check_failures(top: str, todo: pathlib.Path, config: ProjectConfig, own: pat
|
||||
"""Why rank_todo.py --check fails on todo. A checkout of the repo the hook runs from checks with its own bin/rank_todo.py, so a branch that changes the table's shape is held to its own rules. Any other checkout checks with the hook's ranking: running its script would run its code before every commit."""
|
||||
script = pathlib.Path(top) / "bin" / "rank_todo.py"
|
||||
if not script.is_file() or not same_repo(top, own):
|
||||
return plan_file.check_failures(todo, config)
|
||||
return file_plan(config, todo).check()
|
||||
try:
|
||||
ran = subprocess.run([sys.executable, str(script), "--check", str(todo)], capture_output=True, cwd=top, text=True, timeout=OWN_CHECK_SECONDS)
|
||||
except subprocess.TimeoutExpired:
|
||||
|
||||
Reference in New Issue
Block a user