68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
"""What the preflight gathers, which facts.render states."""
|
|
import dataclasses
|
|
import pathlib
|
|
import typing
|
|
|
|
from failure import Failure
|
|
from release_plan.release_standing import LastCut
|
|
from release_plan.next_chunk import NextChunk, NoItem
|
|
|
|
# The CLI that lists a forge's pull requests: gh for a github.com origin, tea for any other.
|
|
Forge = typing.Literal["gh", "tea"]
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Ran:
|
|
"""A command that ran to its end: its exit code and what it printed."""
|
|
code: int
|
|
stdout: str
|
|
stderr: str
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Worktree:
|
|
path: pathlib.Path
|
|
# How it came to be, as the worker reads it.
|
|
how: str
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class NamedPath:
|
|
"""A tracked file or folder the item names, with how many tracked files it holds."""
|
|
span: str
|
|
files: int
|
|
# A file's lines, or why they cannot be read; None for a folder.
|
|
lines: int | Failure | None
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class ItemFacts:
|
|
"""What the preflight found or made for the plan's first item."""
|
|
plan: NextChunk
|
|
worktree: Worktree | Failure
|
|
# The forge whose CLI listed the open pull requests, and how it ran; None without an origin remote.
|
|
pulls: tuple[Forge, Ran | Failure] | None
|
|
named: list[NamedPath] | Failure
|
|
# Each tool run in the worktree, by its command line, and how it ran; none without a worktree.
|
|
tools: list[tuple[str, Ran | Failure]]
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class Gathered:
|
|
"""Everything the preflight read and ran, for facts.render to state."""
|
|
# The default branch's ref, such as origin/main.
|
|
default: str
|
|
# Why origin reads as last fetched; None after a fetch.
|
|
note: str | None
|
|
cut: LastCut
|
|
# What was found or made for the plan's first item; else why the plan names none.
|
|
item: ItemFacts | NoItem
|
|
# The plan that was read, as choices.plan_name names it.
|
|
plan: str
|
|
# Each path the project's config sets, and the epic of a plan kept in Jira, by its setting: in the item's worktree where one was made or continued, else in the checkout.
|
|
places: dict[str, str]
|
|
# Whether the project's config puts the plan outside the checkout, where a release whose items are all done is not seen.
|
|
plan_outside: bool
|
|
# The language and the templates the project's config names, by their settings.
|
|
texts: dict[str, str]
|