diff --git a/backport/backport_pr.py b/backport/backport_pr.py index 079e779c..1ea5fddc 100644 --- a/backport/backport_pr.py +++ b/backport/backport_pr.py @@ -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: diff --git a/backport/tasks.py b/backport/tasks.py index 655969ef..3cf9e60e 100644 --- a/backport/tasks.py +++ b/backport/tasks.py @@ -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() diff --git a/backport/util.py b/backport/util.py index c09e2dcd..e5652971 100644 --- a/backport/util.py +++ b/backport/util.py @@ -36,4 +36,13 @@ def is_cpython_repo(): subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT) except subprocess.SubprocessError: return False - return True \ No newline at end of file + 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 \ No newline at end of file