From e2511d0484fe6889e059eb23f9a785d4368f789a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 28 Sep 2023 11:11:07 +0300 Subject: [PATCH 1/2] Fix whitespace --- miss_islington/tasks.py | 4 ++-- miss_islington/util.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/miss_islington/tasks.py b/miss_islington/tasks.py index d42dc6ef..74ceb399 100644 --- a/miss_islington/tasks.py +++ b/miss_islington/tasks.py @@ -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() @@ -99,7 +99,7 @@ async def backport_task_asyncio( """, ) 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']) diff --git a/miss_islington/util.py b/miss_islington/util.py index 7a60698f..e363f549 100644 --- a/miss_islington/util.py +++ b/miss_islington/util.py @@ -79,4 +79,3 @@ def normalize_title(title, body): else: # Being paranoid in case \r\n is used. return title[:-1] + body[1:].partition("\r\n")[0] - From 42edb8b2ddead69c30a092c0eb4b99da1268043f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 28 Sep 2023 11:20:27 +0300 Subject: [PATCH 2/2] Dedent text to make code blocks copyable --- miss_islington/tasks.py | 41 ++++++++++++++++++++++------------------- miss_islington/util.py | 6 ++---- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/miss_islington/tasks.py b/miss_islington/tasks.py index 74ceb399..62119595 100644 --- a/miss_islington/tasks.py +++ b/miss_islington/tasks.py @@ -91,12 +91,13 @@ 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) @@ -117,13 +118,14 @@ 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() @@ -131,12 +133,13 @@ async def backport_task_asyncio( 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() diff --git a/miss_islington/util.py b/miss_islington/util.py index e363f549..ab28d4ee 100644 --- a/miss_islington/util.py +++ b/miss_islington/util.py @@ -1,8 +1,5 @@ -import re import subprocess - -import gidgethub - +import textwrap async def comment_on_pr(gh, issue_number, message): @@ -10,6 +7,7 @@ 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}")