Skip to content

Commit

Permalink
Remove automerge stuff (#610)
Browse files Browse the repository at this point in the history
* Remove automerge stuff

We will be using GitHub native automerge feature.
We also need to remove some webhook events.
The ones we still need are: pull_request closed and pull_request labeled

For python/core-workflow#498
and #PyConUS #PyConUSChallenge

* Use codecov 2.1.13

* Update dev-requirements.txt

* Update test_util.py

Combine return statements
  • Loading branch information
Mariatta authored Apr 20, 2023
1 parent 2e37958 commit 4fbdb0c
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 3,004 deletions.
4 changes: 2 additions & 2 deletions miss_islington/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from sentry_sdk.integrations.aiohttp import AioHttpIntegration


from . import backport_pr, check_run, delete_branch, status_change
from . import backport_pr, delete_branch

router = routing.Router(
backport_pr.router, delete_branch.router, status_change.router, check_run.router
backport_pr.router, delete_branch.router
)

cache = cachetools.LRUCache(maxsize=500)
Expand Down
34 changes: 0 additions & 34 deletions miss_islington/check_run.py

This file was deleted.

169 changes: 0 additions & 169 deletions miss_islington/status_change.py

This file was deleted.

93 changes: 0 additions & 93 deletions miss_islington/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

import gidgethub

from .status_change import AUTOMERGE_TRAILER

AUTOMERGE_LABEL = ":robot: automerge"


async def comment_on_pr(gh, issue_number, message):
Expand Down Expand Up @@ -83,93 +80,3 @@ def normalize_title(title, body):
# Being paranoid in case \r\n is used.
return title[:-1] + body[1:].partition("\r\n")[0]


def normalize_message(body):
"""Normalize the message body to make it commit-worthy.
Mostly this just means removing HTML comments, but also removes unwanted
leading or trailing whitespace.
Returns the normalized body.
"""
# Remove issue mentions added by Bedevere.
# This should catch both current gh- and legacy bpo- messages.
body = re.sub(r"(?s)<!-- (gh-)?issue-number:.*/\1issue-number -->", "", body)
# Remove other HTML comments
while "<!--" in body:
body = body[: body.index("<!--")] + body[body.index("-->") + 3 :]
# Delete BPO links on their own line, probably added by an old version of Bedevere.
body = re.sub(r"\nhttps://bugs.python.org/issue(\d+)\n", "", body)
# Strip additional newlines between commit body and automerge label.
body_parts = body.split(AUTOMERGE_TRAILER)
if len(body_parts) > 1:
body, automerge_user = body_parts
body = f"{body.strip()}\n\n{AUTOMERGE_TRAILER}{automerge_user}"
return "\n\n" + body.strip()


# Copied over from https://github.com/python/bedevere
async def is_core_dev(gh, username):
"""Check if the user is a CPython core developer."""
org_teams = "/orgs/python/teams"
team_name = "python core"
async for team in gh.getiter(org_teams):
if team["name"].lower() == team_name: # pragma: no branch
break
else:
raise ValueError(f"{team_name!r} not found at {org_teams!r}")
# The 'teams' object only provides a URL to a deprecated endpoint,
# so manually construct the URL to the non-deprecated team membership
# endpoint.
membership_url = f"/teams/{team['id']}/memberships/{username}"
try:
await gh.getitem(membership_url)
except gidgethub.BadRequest as exc:
if exc.status_code == 404:
return False
raise
else:
return True


def pr_is_awaiting_merge(pr_labels):
label_names = [label["name"] for label in pr_labels]
if (
"DO-NOT-MERGE" not in label_names
and "awaiting merge" in label_names
and "CLA not signed" not in label_names
):
return True
return False


def pr_is_automerge(pr_labels):
for label in pr_labels:
if label["name"] == AUTOMERGE_LABEL:
return True
return False


async def get_pr_for_commit(gh, sha):
prs_for_commit = await gh.getitem(
f"/search/issues?q=type:pr+repo:python/cpython+sha:{sha}"
)
if prs_for_commit["total_count"] > 0: # there should only be one
pr_for_commit = prs_for_commit["items"][0]
return pr_for_commit
return None


async def remove_automerge(gh, pr_data):
"""Remove the automerge label"""
await gh.delete(
f"{pr_data['issue_url']}/labels/{AUTOMERGE_LABEL}",
accept="application/vnd.github.symmetra-preview+json",
)


async def get_check_runs_for_sha(gh, sha):
return await gh.getitem(
f"/repos/python/cpython/commits/{sha}/check-runs",
accept="application/vnd.github.antiope-preview+json",
)
Loading

0 comments on commit 4fbdb0c

Please sign in to comment.