Answer stability round 1: 0 🔴, 3 🟡 (0 misread); bound the forge's CLI with a timeout in one runner, and read a pull request from a deleted fork
CI / tests (pull_request) Successful in 3m20s

This commit is contained in:
Lilleman
2026-11-19 23:30:30 +01:00
parent 356ae263e1
commit 0c52688ff8
7 changed files with 35 additions and 30 deletions
+3 -3
View File
@@ -56,9 +56,9 @@ class ReadyPull:
def ready_pulls(forge: Forge, run: Run) -> list[ReadyPull] | Failure:
"""Each open pull request from origin's own branches that is no draft, which Gitea tells by its title (GITEA_DRAFT). A row is left out where its head is no commit ID, since the caller passes the head to git, or where its number is not all digits, since the caller prints it."""
"""Each open pull request from origin's own branches that is no draft, which Gitea tells by its title (GITEA_DRAFT); Gitea names no head repo for a fork that was deleted. A row is left out where its head is no commit ID, since the caller passes the head to git, or where its number is not all digits, since the caller prints it."""
if forge == "gh":
# 100 is the most GitHub's API lists a page; gh lists 30 unless told.
# A limit: an awaited pull request past the first 100 open ones, drafts and forks counted, is not seen. `--draft=false` would make gh search, and GitHub's search index lags a pull request just marked ready.
listed = run(["gh", "pr", "list", "--limit", "100", "--json", "number,url,headRefOid,isDraft,isCrossRepository", "--template", "{{range .}}{{.number}}\t{{.url}}\t{{.headRefOid}}\t{{.isDraft}}\t{{.isCrossRepository}}\n{{end}}"])
if isinstance(listed, Failure):
return listed
@@ -69,7 +69,7 @@ def ready_pulls(forge: Forge, run: Run) -> list[ReadyPull] | Failure:
if isinstance(pulls, Failure):
return pulls
try:
found = [ReadyPull(str(pull["number"]), pull["html_url"], pull["head"]["sha"]) for pull in pulls if pull["head"]["repo"]["full_name"] == pull["base"]["repo"]["full_name"] and not pull["title"].upper().startswith(GITEA_DRAFT)]
found = [ReadyPull(str(pull["number"]), pull["html_url"], pull["head"]["sha"]) for pull in pulls if (pull["head"]["repo"] or {}).get("full_name") == pull["base"]["repo"]["full_name"] and not pull["title"].upper().startswith(GITEA_DRAFT)]
except (AttributeError, KeyError, TypeError):
return Failure(f"tea api listed pull requests in a shape that can't be read: {str(pulls)[:200]}")
return [pull for pull in found if pull.number.isascii() and pull.number.isdigit() and isinstance(pull.head, str) and re.fullmatch(r"[0-9a-f]{40,64}", pull.head)]