Answer stability round 1: 1 🔴, 5 🟡 (0 misread); hold a pull request's base on the forge to the recorded one, ask origin for the epic branch, and name where a chunk's work landed
CI / tests (pull_request) Successful in 3m46s

This commit is contained in:
Lilleman
2026-11-20 21:42:32 +01:00
parent 525f3f8836
commit d464f271bf
13 changed files with 352 additions and 74 deletions
+31
View File
@@ -103,6 +103,37 @@ def unmergeable(forge: Forge, number: str, run: Run) -> str | None | Failure:
return Failure(f"tea api answered pull request {number} in a shape that can't be read: {str(pull)[:200]}")
def other_base(forge: Forge, number: str, base: str, run: Run) -> Failure | None:
"""A Failure, naming both branches, where the forge merges pull request number into another branch than base, the one its checkout takes. None where the two agree.
A tool decides from the checkout's base who merges the pull request, so it doesn't act on one the forge would merge elsewhere."""
onto = base_branch(forge, number, run)
if isinstance(onto, Failure) or onto == base:
return onto if isinstance(onto, Failure) else None
return Failure(f"pull request #{number} merges into {onto} on the forge, but this checkout takes {base} as the base of its branch; a person settles which holds, and changes the pull request's base on the forge or the branch's `chunk-base` in git's config")
def base_branch(forge: Forge, number: str, run: Run) -> str | Failure:
"""The branch the forge merges pull request number into."""
if forge == "gh":
viewed = run(["gh", "pr", "view", number, "--json", "baseRefName"])
if isinstance(viewed, Failure):
return viewed
try:
name = json.loads(viewed)["baseRefName"]
except (ValueError, KeyError, TypeError):
name = None
return name if name and isinstance(name, str) else Failure(f"gh pr view printed no base branch: {viewed.strip()[:200]}")
pull = gitea(run, f"repos/{{owner}}/{{repo}}/pulls/{number}")
if isinstance(pull, Failure):
return pull
try:
name = pull["base"]["ref"]
except (KeyError, TypeError):
name = None
return name if name and isinstance(name, str) else Failure(f"tea api answered pull request {number} in a shape that can't be read: {str(pull)[:200]}")
def required_checks(forge: Forge, base: str, run: Run) -> set[str] | Failure:
"""The checks, or glob patterns of checks, that the forge's protection of the branch base requires before a merge. None on GitHub, where gh's watch covers them.