Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions miss_islington/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@app.task()
def setup_cpython_repo():
print("Setting up CPython repository") # pragma: nocover
print("Setting up CPython repository") # pragma: nocover
if "cpython" not in os.listdir("."):
subprocess.check_output(
f"git clone https://{os.environ.get('GH_AUTH')}:x-oauth-basic@github.com/miss-islington/cpython.git".split()
Expand Down Expand Up @@ -91,15 +91,16 @@ async def backport_task_asyncio(
await util.comment_on_pr(
gh,
issue_number,
f"""{util.get_participants(created_by, merged_by)}, I can't backport for now. Please try again later or
backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.
```
cherry_picker {commit_hash} {branch}
```
""",
f"""\
{util.get_participants(created_by, merged_by)}, I can't backport for now. Please try again later or
backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.
```
cherry_picker {commit_hash} {branch}
```
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)

# Ensure that we don't have any changes lying around
subprocess.check_output(['git', 'reset', '--hard'])
subprocess.check_output(['git', 'clean', '-fxd'])
Expand All @@ -117,26 +118,28 @@ async def backport_task_asyncio(
await util.comment_on_pr(
gh,
issue_number,
f"""Sorry {util.get_participants(created_by, merged_by)}, I had trouble checking out the `{branch}` backport branch.
Please retry by removing and re-adding the "needs backport to {branch}" label.
Alternatively, you can backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on the command line.
```
cherry_picker {commit_hash} {branch}
```
""",
f"""\
Sorry {util.get_participants(created_by, merged_by)}, I had trouble checking out the `{branch}` backport branch.
Please retry by removing and re-adding the "needs backport to {branch}" label.
Alternatively, you can backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on the command line.
```
cherry_picker {commit_hash} {branch}
```
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)
cp.abort_cherry_pick()
except cherry_picker.CherryPickException:
await util.comment_on_pr(
gh,
issue_number,
f"""Sorry, {util.get_participants(created_by, merged_by)}, I could not cleanly backport this to `{branch}` due to a conflict.
Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.
```
cherry_picker {commit_hash} {branch}
```
""",
f"""\
Sorry, {util.get_participants(created_by, merged_by)}, I could not cleanly backport this to `{branch}` due to a conflict.
Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.
```
cherry_picker {commit_hash} {branch}
```
""",
)
await util.assign_pr_to_core_dev(gh, issue_number, merged_by)
cp.abort_cherry_pick()
Expand Down
7 changes: 2 additions & 5 deletions miss_islington/util.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import re
import subprocess

import gidgethub

import textwrap


async def comment_on_pr(gh, issue_number, message):
"""
Leave a comment on a PR/Issue
"""
issue_comment_url = f"/repos/python/cpython/issues/{issue_number}/comments"
message = textwrap.dedent(message)
data = {"body": message}
response = await gh.post(issue_comment_url, data=data)
print(f"Commented at {response['html_url']}, message: {message}")
Expand Down Expand Up @@ -79,4 +77,3 @@ def normalize_title(title, body):
else:
# Being paranoid in case \r\n is used.
return title[:-1] + body[1:].partition("\r\n")[0]