Skip to content

Commit b72583c

Browse files
authored
If PR author is the same as the committer, only mention them once. (GH-19)
Closes python/miss-islington#18
1 parent e9681cd commit b72583c

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

backport/backport_pr.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ async def backport_pr(event, gh, *args, **kwargs):
2727
if label['name'].startswith("needs backport to")]
2828

2929
if branches:
30-
message = "🐍🍒⛏🤖 " \
31-
f"Thanks @{created_by} for the PR, and @{merged_by} for merging it 🌮🎉." \
32-
f"I'm working now to backport this PR to: {', '.join(branches)}."
30+
thanks_to = ""
31+
if created_by == merged_by:
32+
thanks_to = f"Thanks @{created_by} for the PR 🌮🎉."
33+
else:
34+
thanks_to = f"Thanks @{created_by} for the PR, and @{merged_by} for merging it 🌮🎉."
35+
message = f"""\
36+
{thanks_to}. I'm working now to backport this PR to: {', '.join(branches)}.
37+
🐍🍒⛏🤖
38+
"""
3339
util.comment_on_pr(issue_number, message)
3440

3541
for branch in branches:

backport/tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
3737
cp.backport()
3838
except cherry_picker.BranchCheckoutException:
3939
util.comment_on_pr(issue_number,
40-
f"""Sorry @{created_by} and @{merged_by}, I had trouble checking out the `{branch}` backport branch.
40+
f"""Sorry {util.get_participants(created_by, merged_by)}, I had trouble checking out the `{branch}` backport branch.
4141
Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.""")
4242
cp.abort_cherry_pick()
4343
except cherry_picker.CherryPickException:
4444
util.comment_on_pr(issue_number,
45-
f"""Sorry, @{created_by} and @{merged_by}, I could not cleanly backport this to `{branch}` due to a conflict.
45+
f"""Sorry, {util.get_participants(created_by, merged_by)}, I could not cleanly backport this to `{branch}` due to a conflict.
4646
Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.""")
4747
cp.abort_cherry_pick()

backport/util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ def is_cpython_repo():
3737
except subprocess.SubprocessError:
3838
return False
3939
return True
40+
41+
42+
def get_participants(created_by, merged_by):
43+
participants = ""
44+
if created_by == merged_by:
45+
participants = f"@{created_by}"
46+
else:
47+
participants = f"@{created_by} and @{merged_by}"
48+
return participants

0 commit comments

Comments
 (0)