Add the project setting merge = "human", under which chunk-pr merge leaves the pull request ready and a do-epic chunk parks on your merge
This commit is contained in:
@@ -81,7 +81,7 @@ class Checkout:
|
||||
return failed
|
||||
texts = {name: str(answer).strip() for name, answer in named.items()}
|
||||
paths = {name: pathlib.Path(texts[name]) for name in ("plan", "changelog", "comprehension-history") if texts.get(name, "").startswith("/")}
|
||||
return ProjectConfig("proj", pathlib.Path("/config"), pathlib.Path("/checkout"), paths, wait_for_approval=texts.get("wait-for-approval") == "true", commit_title=texts.get("commit-title", "{summary}"), pull_request_title=texts.get("pull-request-title", "{summary}"), branch=texts.get("branch", "item-{id}"))
|
||||
return ProjectConfig("proj", pathlib.Path("/config"), pathlib.Path("/checkout"), paths, wait_for_approval=texts.get("wait-for-approval") == "true", merge=texts.get("merge", "chunk"), commit_title=texts.get("commit-title", "{summary}"), pull_request_title=texts.get("pull-request-title", "{summary}"), branch=texts.get("branch", "item-{id}"))
|
||||
|
||||
def __call__(self, command: list[str]) -> str | Failure:
|
||||
self.ran.append(command)
|
||||
@@ -360,6 +360,47 @@ class Merge(unittest.TestCase):
|
||||
checkout.decisions = list(decisions) or ["APPROVED"]
|
||||
return checkout
|
||||
|
||||
def merged_by_a_human(self, origin: str = GITHUB) -> Checkout:
|
||||
"""A Checkout whose project config sets `merge = "human"`."""
|
||||
checkout = Checkout(origin, open=True)
|
||||
checkout.answers[(PROJECT_CONFIG, "merge")] = "human\n"
|
||||
return checkout
|
||||
|
||||
def test_under_a_humans_merge_it_waits_for_the_checks_marks_the_pull_request_ready_and_leaves_it_unmerged(self):
|
||||
for origin, ready in ((GITHUB, ["gh", "pr", "ready", "12"]), (GITEA, ["tea", "pulls", "edit", "12", "--ready"])):
|
||||
with self.subTest(origin):
|
||||
checkout = self.merged_by_a_human(origin)
|
||||
done = step(["merge"], checkout, checkout.config)
|
||||
self.assertEqual(done, "Marked pull request #12 ready. It passed its checks and awaits a person's merge, since the project's config sets `merge = \"human\"`: leave the merge to them, and report the chunk as ready to merge. Once it is merged, run chunk-pr clean in this worktree.")
|
||||
self.assertEqual(checkout.acted()[-1], ready)
|
||||
self.assertFalse(any("merge" in command[1:4] for command in checkout.acted() if command[0] != "git"), checkout.acted())
|
||||
|
||||
def test_under_a_humans_merge_a_chunk_that_parks_is_told_to_end_its_run(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
done = merged(checkout, checkout.config, self.fail, parks=True)
|
||||
self.assertEqual(done, "Marked pull request #12 ready. It passed its checks and awaits a person's merge, since the project's config sets `merge = \"human\"`: end your run now, since do-epic parks the chunk and resumes this session once it is merged or a reviewer comments.")
|
||||
|
||||
def test_under_a_humans_merge_a_failed_check_leaves_the_pull_request_as_it_was(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
checkout.answers[tuple(GH_CHECKS)] = Failure("gh pr checks 12: CI / tests\tfail")
|
||||
self.assertEqual(step(["merge"], checkout, checkout.config), Failure("gh pr checks 12: CI / tests\tfail"))
|
||||
self.assertEqual(changes(checkout), [])
|
||||
|
||||
def test_under_a_humans_merge_it_never_reads_the_approval_also_on_gitea(self):
|
||||
for origin in (GITHUB, GITEA):
|
||||
with self.subTest(origin):
|
||||
checkout = self.merged_by_a_human(origin)
|
||||
checkout.answers[tuple(WAITS)] = "true\n"
|
||||
checkout.decisions = ["REVIEW_REQUIRED"]
|
||||
self.assertIn("awaits a person's merge", str(step(["merge"], checkout, checkout.config)))
|
||||
self.assertNotIn(GH_DECISION, checkout.ran)
|
||||
|
||||
def test_under_a_humans_merge_the_plan_items_are_finished_on_the_branch_so_they_land_with_the_merge(self):
|
||||
checkout = self.merged_by_a_human()
|
||||
done = step(["merge", "--finish", "7", "--no-changelog"], checkout, checkout.config)
|
||||
self.assertIn("awaits a person's merge", str(done))
|
||||
self.assertIn([MergeQueue.TODO_ITEM, "finish", "7", "--no-changelog"], checkout.ran)
|
||||
|
||||
def test_a_project_without_wait_for_approval_never_reads_the_review_decision(self):
|
||||
checkout = Checkout(GITHUB, open=True)
|
||||
checkout.decisions = ["REVIEW_REQUIRED"]
|
||||
|
||||
Reference in New Issue
Block a user