Answer stability round 2: 0 🔴, 1 🟡 (0 misread); a test of the last poll, early returns in pushed, a plainer gh row match

This commit is contained in:
2026-11-27 16:02:59 +01:00
parent f46946f6de
commit 1703f0d47b
3 changed files with 14 additions and 4 deletions
+7 -3
View File
@@ -379,11 +379,15 @@ def pushed(run: Run, config: Config, sleep: typing.Callable[[float], None]) -> s
if isinstance(sent, Failure):
return sent
comment = review_comment(run, config)
number = None if comment is None or isinstance(comment, Failure) else shown_pull(forge, branch, head, run, sleep)
if isinstance(comment, Failure):
return Failure(f"pushed {branch}, but could not ask for a review: {comment.reason}")
if isinstance(number, Failure) or number is None or comment is None:
return number if isinstance(number, Failure) else f"Pushed {branch}."
if comment is None:
return f"Pushed {branch}."
number = shown_pull(forge, branch, head, run, sleep)
if number is None:
return f"Pushed {branch}."
if isinstance(number, Failure):
return number
made = comment_on(forge, number, comment, run)
return Failure(f"pushed {branch}, but could not ask for a review: {made.reason}") if isinstance(made, Failure) else f"Pushed {branch}, and asked for a review of pull request #{number} with “{comment}”."
+6
View File
@@ -1232,6 +1232,12 @@ class EpicBranch(unittest.TestCase):
self.assertEqual(sum(slept), 60)
self.assertNotIn(self.COMMENT_GH, checkout.ran)
def test_push_asks_for_a_review_where_the_forge_shows_the_new_head_at_the_last_poll(self):
checkout, slept = self.checkout(), []
checkout.listed_heads = [OLD] * 24 + [HEAD]
self.assertIn("asked for a review of pull request #12", str(step(["push"], checkout, checkout.config, sleep=slept.append)))
self.assertEqual(sum(slept), 60)
def test_push_does_not_wait_where_the_pull_request_goes_into_the_default_branch(self):
checkout, slept = self.checkout(), []
checkout.chunk_base = ""
+1 -1
View File
@@ -39,7 +39,7 @@ def pull_at(forge: Forge, branch: str, head: str | None, state: typing.Literal["
if isinstance(listed, Failure):
return listed
rows = [line.split("\t") for line in listed.splitlines()]
return next((row[0] for row in rows if row[1:] == ([head, "false"] if head is not None else row[1:2] + ["false"])), None)
return next((row[0] for row in rows if len(row) == 3 and row[2] == "false" and head in (None, row[1])), None)
# Gitea lists at most 50 a page; the pull request sought is among the newest. Gitea has no merged state: a merged pull request is a closed one marked merged.
pulls = gitea(run, f"repos/{{owner}}/{{repo}}/pulls?state={'open' if state == 'open' else 'closed'}&limit=50")
if isinstance(pulls, Failure):