Answer product-owner round 1: 2 🔴, 2 🟡 (0 misread); rebuild a branch main moved past, drop a tag whose push failed, refuse another project's clone, say which pull request it waits for

This commit is contained in:
2026-11-08 10:51:29 +01:00
parent f6e96da675
commit 51f5f3be29
6 changed files with 103 additions and 37 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
"""A cut's pull request steps on the forge origin lives on: gh on GitHub, tea elsewhere, as chunk_preflight tells them apart.
"""The pull request steps of a cut. They run gh where origin is on GitHub and tea elsewhere, as chunk_preflight tells the two apart.
Each step is pinned to head, the commit origin's release branch points at: the cut takes only a pull request from origin itself whose head is that commit, and the forge merges it only while its head is still that commit. So a fork's pull request from a branch of the same name, or a push to the branch after its checks passed, is never merged.
"""
@@ -10,7 +10,7 @@ import typing
from failure import Failure
from chunk_preflight.choices import Forge
# How long tea waits between two reads of the pull request's checks.
# How long the cut waits between two reads of the head commit's status on Gitea.
POLL_SECONDS = 10
# Runs a command in the clone: what it printed, or a Failure with its reason.
@@ -30,7 +30,7 @@ def runner(cwd: str) -> Run:
def gitea(run: Run, endpoint: str, *fields: str) -> typing.Any | Failure:
"""What Gitea's API answered at endpoint, parsed; with fields, `key=value` strings, a POST of them. tea api exits 0 on an HTTP error too, so an answer holding only Gitea's `message` is a Failure."""
"""What Gitea's API answered at endpoint, parsed; with fields, `key=value` strings, a POST of them. tea api exits 0 on an HTTP error too, so an answer with Gitea's `message` key is a Failure."""
answered = run(["tea", "api", *(["--method", "POST"] if fields else []), *[word for field in fields for word in ("--field", field)], endpoint])
if isinstance(answered, Failure) or not answered.strip():
return answered
@@ -92,7 +92,7 @@ def checks_passed(forge: Forge, number: str, head: str, run: Run, sleep: typing.
def merge(forge: Forge, number: str, head: str, run: Run) -> Failure | None:
"""Merge pull request number fast-forward only, refused by the forge where its head is no longer head."""
"""Merge pull request number, fast-forward only on Gitea and by rebase on GitHub. The forge refuses where the pull request's head is no longer head."""
if forge == "gh":
# GitHub has no fast-forward-only merge. A rebase merge of a branch already on top of main is the nearest, though it may give the commit a new hash, so the cut finds it on main by its title.
merged = run(["gh", "pr", "merge", number, "--rebase", "--match-head-commit", head])