Answer stability round 2: 1 🔴, 0 🟡 (0 misread); match Gitea pull requests by head label, which survives origin deleting a merged branch

This commit is contained in:
2026-11-10 11:13:26 +01:00
parent 67c7c979a0
commit 23b7848be6
4 changed files with 6 additions and 5 deletions
+2 -1
View File
@@ -69,7 +69,8 @@ def pull_at(forge: Forge, branch: str, head: str, state: typing.Literal["open",
if isinstance(pulls, Failure):
return pulls
try:
return next((str(pull["number"]) for pull in pulls if pull["head"]["ref"] == branch and pull["head"]["sha"] == head and pull["head"]["repo"]["full_name"] == pull["base"]["repo"]["full_name"] and (state == "open" or pull["merged"] is True)), None)
# Match the label, not the ref: once origin deletes a merged branch, Gitea reports its ref as refs/pull/<N>/head.
return next((str(pull["number"]) for pull in pulls if pull["head"]["label"] == branch and pull["head"]["sha"] == head and pull["head"]["repo"]["full_name"] == pull["base"]["repo"]["full_name"] and (state == "open" or pull["merged"] is True)), None)
except (KeyError, TypeError):
return Failure(f"tea api listed pull requests in a shape that can't be read: {str(pulls)[:200]}")