Skip to content

Commit

Permalink
If PR author is the same as the committer, only mention them once.
Browse files Browse the repository at this point in the history
Closes python#18
  • Loading branch information
Mariatta committed Sep 9, 2017
1 parent d96e3c1 commit 37c4d47
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 9 additions & 3 deletions backport/backport_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ async def backport_pr(event, gh, *args, **kwargs):
if label['name'].startswith("needs backport to")]

if branches:
message = "🐍🍒⛏🤖 " \
f"Thanks @{created_by} for the PR, and @{merged_by} for merging it 🌮🎉." \
f"I'm working now to backport this PR to: {', '.join(branches)}."
thanks_to = ""
if created_by == merged_by:
thanks_to = f"Thanks @{created_by} for the PR 🌮🎉."
else:
thanks_to = f"Thanks @{created_by} for the PR, and @{merged_by} for merging it 🌮🎉."
message = f"""\
{thanks_to}. I'm working now to backport this PR to: {', '.join(branches)}.
🐍🍒⛏🤖
"""
util.comment_on_pr(issue_number, message)

for branch in branches:
Expand Down
4 changes: 2 additions & 2 deletions backport/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by):
cp.backport()
except cherry_picker.BranchCheckoutException:
util.comment_on_pr(issue_number,
f"""Sorry @{created_by} and @{merged_by}, I had trouble checking out the `{branch}` backport branch.
f"""Sorry {util.get_participants(created_by, merged_by)}, I had trouble checking out the `{branch}` backport branch.
Please backport using [cherry_picker](https://pypi.org/project/cherry-picker/) on command line.""")
cp.abort_cherry_pick()
except cherry_picker.CherryPickException:
util.comment_on_pr(issue_number,
f"""Sorry, @{created_by} and @{merged_by}, I could not cleanly backport this to `{branch}` due to a conflict.
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.""")
cp.abort_cherry_pick()
11 changes: 10 additions & 1 deletion backport/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ def is_cpython_repo():
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
except subprocess.SubprocessError:
return False
return True
return True


def get_participants(created_by, merged_by):
participants = ""
if created_by == merged_by:
participants = f"@{created_by}"
else:
participants = f"@{created_by} and @{merged_by}"
return participants

0 comments on commit 37c4d47

Please sign in to comment.