Answer stability round 1: 1 🔴, 1 🟡 (0 misread); wait for a pull request at another head, and only where a review is owed
This commit is contained in:
@@ -25,7 +25,6 @@ GITEA = "ssh://git@gitea.example.org:22/me/project.git"
|
||||
HEAD = "c0ffee" * 7
|
||||
PUSH = ["git", "push", "--quiet", "--set-upstream", "origin", "item-7"]
|
||||
OLD = "badc0de" * 6
|
||||
OLD_HEAD = ["git", "ls-remote", "origin", "refs/heads/item-7"]
|
||||
GH_LIST = ["gh", "pr", "list", "--head", "item-7", "--json", "number,headRefOid,isCrossRepository", "--template", "{{range .}}{{.number}}\t{{.headRefOid}}\t{{.isCrossRepository}}\n{{end}}"]
|
||||
TEA_LIST = ["tea", "api", "repos/{owner}/{repo}/pulls?state=open&limit=50"]
|
||||
GH_SETTINGS = ["gh", "repo", "view", "--json", "mergeCommitAllowed,rebaseMergeAllowed,squashMergeAllowed"]
|
||||
@@ -127,7 +126,7 @@ class Checkout:
|
||||
|
||||
def acted(self) -> list[list[str]]:
|
||||
"""What it ran beyond reading the checkout, the pull requests and the repository's settings."""
|
||||
reads = [OLD_HEAD, GH_LIST, GH_DECISION, GH_BASE, TEA_LIST, TEA_PULL, GH_SETTINGS, TEA_SETTINGS, OWED, GH_CHECKS, TEA_BRANCH, TEA_STATUS, GH_THREADS]
|
||||
reads = [GH_LIST, GH_DECISION, GH_BASE, TEA_LIST, TEA_PULL, GH_SETTINGS, TEA_SETTINGS, OWED, GH_CHECKS, TEA_BRANCH, TEA_STATUS, GH_THREADS]
|
||||
return [command for command in self.ran if tuple(command) not in self.answers and command not in reads]
|
||||
|
||||
|
||||
@@ -1092,6 +1091,8 @@ class EpicBranch(unittest.TestCase):
|
||||
|
||||
def test_a_branch_whose_base_git_does_not_record_merges_into_the_default_branch(self):
|
||||
self.assertEqual(base_of("item-7", self.unrecorded), Base("main", False))
|
||||
|
||||
def test_a_recorded_base_is_an_epics_working_branch_unless_it_is_the_default_branch(self):
|
||||
self.assertEqual(base_of("item-7", self.recorded("main")), Base("main", False))
|
||||
self.assertEqual(base_of("item-7", self.recorded("ABC-1")), Base("ABC-1", True))
|
||||
|
||||
@@ -1210,31 +1211,31 @@ class EpicBranch(unittest.TestCase):
|
||||
|
||||
def test_push_waits_for_the_forge_to_show_the_new_head_before_it_asks_for_a_review(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.answers[tuple(OLD_HEAD)] = f"{OLD}\trefs/heads/item-7\n"
|
||||
checkout.listed_heads = [OLD, OLD, OLD, OLD, HEAD]
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7, and asked for a review of pull request #12 with “@reviewer review”.")
|
||||
self.assertEqual(slept, [5, 5])
|
||||
|
||||
def test_push_fails_naming_the_pull_request_where_the_forge_never_shows_the_new_head(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.answers[tuple(OLD_HEAD)] = f"{OLD}\trefs/heads/item-7\n"
|
||||
checkout.listed_heads = [OLD]
|
||||
done = step(["push"], checkout, checkout.config, sleep=slept.append)
|
||||
self.assertEqual(done, Failure(f"pushed item-7, but the forge still shows pull request #12 at {OLD[:12]}, not at {HEAD[:12]}, after 60 seconds, so no review was asked for; run chunk-pr push again"))
|
||||
self.assertIsInstance(done, Failure)
|
||||
for fact in ("pushed item-7", "pull request #12", HEAD[:12], "60 seconds"):
|
||||
self.assertIn(fact, done.reason)
|
||||
self.assertEqual(sum(slept), 60)
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
|
||||
def test_push_waits_for_no_pull_request_that_was_not_open_at_the_old_head(self):
|
||||
checkout, slept = self.checkout(open=False), []
|
||||
checkout.answers[tuple(OLD_HEAD)] = f"{OLD}\trefs/heads/item-7\n"
|
||||
def test_push_does_not_wait_where_the_pull_request_goes_into_the_default_branch(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.chunk_base = ""
|
||||
checkout.listed_heads = [OLD]
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7.")
|
||||
self.assertEqual(slept, [])
|
||||
|
||||
def test_a_push_whose_old_head_cannot_be_read_pushes_nothing(self):
|
||||
checkout = self.checkout()
|
||||
checkout.answers[tuple(OLD_HEAD)] = Failure("git ls-remote: no network")
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), Failure("git ls-remote: no network"))
|
||||
self.assertNotIn(PUSH, checkout.ran)
|
||||
def test_push_does_not_wait_where_no_pull_request_is_open(self):
|
||||
checkout, slept = self.checkout(open=False), []
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7.")
|
||||
self.assertEqual(slept, [])
|
||||
|
||||
def test_a_failed_push_asks_for_no_review(self):
|
||||
checkout = self.checkout()
|
||||
|
||||
Reference in New Issue
Block a user