Move the forge helpers into bin/forge/, which chunk_preflight, chunk_pr, deploy_release and larv_review import
CI / tests (pull_request) Successful in 3m9s

This commit is contained in:
2026-11-16 23:42:01 +01:00
parent 4b5086153a
commit 73600d7288
18 changed files with 179 additions and 145 deletions
+1 -5
View File
@@ -1,7 +1,7 @@
"""The pure choices the preflight's steps act on."""
import pathlib
from chunk_preflight.gathered import Forge
from forge.commands import Forge
# The command each forge's CLI lists pull requests with; pulls_command adds the flags that pick their rows and fields.
PULLS_LIST: dict[Forge, tuple[str, ...]] = {"gh": ("gh", "pr", "list"), "tea": ("tea", "pulls", "list")}
@@ -26,10 +26,6 @@ def worktree_add(branch: str, path: pathlib.Path, default: str, local: bool, pus
return ["worktree", "add", "--quiet", "--no-track", "-b", branch, str(path), default], f"added on the new branch {branch}, made off {default}."
def forge_of(origin_url: str) -> Forge:
return "gh" if "github.com" in origin_url else "tea"
def pulls_command(forge: Forge, branch: str) -> list[str]:
"""The command that lists open pull requests: gh only branch's, by number and URL; tea every one, by index, head and URL, for facts.open_pulls to pick branch's."""
if forge == "gh":
+2 -1
View File
@@ -4,7 +4,8 @@ from touch_predictions.beside import chunks_beside
from release_plan.next_chunk import cut_name, NextChunk, NoItem
from release_plan.release_standing import dated_cut, LastCut, unreleased_entries, UNSEEN_RELEASES
from failure import Failure
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, Ran
from forge.commands import Forge
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran
from text_files.markdown_text import listed, quoted
from chunk_preflight.choices import PULLS_LIST
from plan.release import version
+1 -4
View File
@@ -1,15 +1,12 @@
"""What the preflight gathers, which facts.render states."""
import dataclasses
import pathlib
import typing
from failure import Failure
from forge.commands import Forge
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:
+3 -2
View File
@@ -78,13 +78,14 @@ import typing
from git_cli.git_repo import commit_exists, default_branch, file_at, git, top
from failure import Failure
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, Ran, Worktree
from chunk_preflight.choices import forge_of, pulls_command, worktree_add, worktree_on
from forge.commands import Forge, forge_of
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran, Worktree
from chunk_preflight.facts import JOINING_DETAILS, render
from project_config.main import located
from plan.named_paths import named_paths
from release_plan.next_chunk import NextChunk, NoItem, plan_name, planned
from release_plan.release_standing import project_plan
from chunk_preflight.choices import pulls_command, worktree_add, worktree_on
BIN = pathlib.Path(__file__).resolve().parents[1]
# Each tool run in the item's worktree, {item} standing for the item's ID.
+1 -5
View File
@@ -13,7 +13,6 @@ from project_config.templates import BRANCH
from release_plan.next_chunk import CarriedOver, NoItem
from chunk_preflight import choices
from failure import Failure
from chunk_preflight.choices import forge_of, worktree_add
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran, Worktree
from test_env import isolated_env
from release_plan.release_standing import LastCut, UNSEEN_RELEASES
@@ -21,6 +20,7 @@ from chunk_preflight.main import line_count, ran, seconds, TIMEOUT
from release_plan import next_chunk
from chunk_preflight.facts import open_pulls, render
from plan_store.todo_md import plan_of
from chunk_preflight.choices import worktree_add
from project_config.test_project_config import write_config
BIN = pathlib.Path(__file__).resolve().parents[1]
@@ -653,10 +653,6 @@ class Gathering(unittest.TestCase):
self.assertEqual(worktree_add("item-3", path, "origin/main", False, True)[0], ["worktree", "add", "--quiet", "--track", "-b", "item-3", "/c/proj-item-3", "origin/item-3"])
self.assertEqual(worktree_add("item-3", path, "origin/main", False, False)[0], ["worktree", "add", "--quiet", "--no-track", "-b", "item-3", "/c/proj-item-3", "origin/main"])
def test_lists_pull_requests_with_gh_on_a_github_origin_and_with_tea_elsewhere(self):
self.assertEqual(forge_of("git@github.com:o/r.git"), "gh")
self.assertEqual(forge_of("https://gitea.larvit.se/o/r.git"), "tea")
def test_reads_the_timeout_setting_as_seconds_above_0_and_else_takes_the_default(self):
self.assertEqual(seconds(None), TIMEOUT)
self.assertEqual(seconds("2.5"), 2.5)