Skip to content

Commit

Permalink
If PR author is the same as the committer, only mention them once. (G…
Browse files Browse the repository at this point in the history
…H-19)

Closes #18
  • Loading branch information
Mariatta authored Sep 9, 2017
1 parent e9681cd commit b72583c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 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()
9 changes: 9 additions & 0 deletions backport/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ def is_cpython_repo():
except subprocess.SubprocessError:
return False
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 b72583c

Please sign in to comment.