Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8fe9d1f

Browse filesBrowse files
authored
Don't merge PR unless it has "awaiting merge" label (#112)
Change the behavior for when deciding when miss-islington should merge the PR. Previously it checks if the PR has one core dev who approved the PR. But that is unreliable because the review may be dismissed later, or another core dev might decide not to backport the PR anymore. The "awaiting merge" label is a better indicator that the PR is ready for merge. Adjust tests. Fixes python/miss-islington#62
1 parent 863dde5 commit 8fe9d1f
Copy full SHA for 8fe9d1f

File tree

5 files changed

+230
-117
lines changed
Filter options

5 files changed

+230
-117
lines changed

‎miss_islington/status_change.py

Copy file name to clipboardExpand all lines: miss_islington/status_change.py
+9-13Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@ async def check_status(event, gh, *args, **kwargs):
2222
await check_ci_status_and_approval(gh, sha, leave_comment=True)
2323

2424

25-
@router.register("pull_request_review", action="submitted")
25+
@router.register("pull_request", action="labeled")
2626
async def pr_reviewed(event, gh, *args, **kwargs):
2727
if event.data["pull_request"]["user"]["login"] == "miss-islington":
28-
reviewer = event.data["review"]["user"]["login"]
29-
approved = event.data["review"]["state"] == "approved"
30-
if approved and await util.is_core_dev(gh, reviewer):
31-
sha = event.data["review"]["commit_id"]
28+
if util.pr_is_awaiting_merge(event.data["pull_request"]["labels"]):
29+
sha = event.data["pull_request"]["head"]["sha"]
3230
await check_ci_status_and_approval(gh, sha)
3331

3432

@@ -75,14 +73,12 @@ async def check_ci_status_and_approval(gh, sha, leave_comment=False):
7573
)
7674

7775
if result["state"] == "success":
78-
async for review in gh.getiter(
79-
f"/repos/python/cpython/pulls/{pr_number}/reviews"
80-
):
81-
reviewer = review["user"]["login"]
82-
approved = review["state"].lower() == "approved"
83-
if approved and await util.is_core_dev(gh, reviewer):
84-
await merge_pr(gh, pr_number, sha)
85-
break
76+
pr = await gh.getitem(
77+
f"/repos/python/cpython/pulls/{pr_number}"
78+
)
79+
if util.pr_is_awaiting_merge(pr["labels"]):
80+
await merge_pr(gh, pr_number, sha)
81+
break
8682

8783

8884
async def merge_pr(gh, pr_number, sha):

‎miss_islington/util.py

Copy file name to clipboardExpand all lines: miss_islington/util.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,10 @@ async def is_core_dev(gh, username):
104104
raise
105105
else:
106106
return True
107+
108+
109+
def pr_is_awaiting_merge(pr_labels):
110+
for label in pr_labels:
111+
if label["name"] == "awaiting merge":
112+
return True
113+
return False

‎tests/test_delete_branch.py

Copy file name to clipboardExpand all lines: tests/test_delete_branch.py
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ class FakeGH:
77
def __init__(self):
88
self.post_data = None
99

10-
async def post(self, url, *, data):
11-
self.post_url = url
12-
self.post_data = data
13-
1410
async def delete(self, url):
1511
self.delete_url = url
1612

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.