Skip to content

Commit f4c5c7a

Browse files
authored
Only backport and leave comment if backport labels are found. (#2)
1 parent e728050 commit f4c5c7a

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

โ€Žbackport/backport_pr.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ async def backport_pr(event, gh, *args, **kwargs):
2121
{'number': f"{event.data['pull_request']['number']}"})
2222

2323
pr_labels = await gh.getitem(gh_issue['labels_url'])
24-
branches = [label['name'].split()[-1] for label in pr_labels if label['name'].startswith("needs backport to")]
25-
26-
message = "๐Ÿ๐Ÿ’โ›๐Ÿค–" \
27-
f"Thanks @{created_by} for the PR, and @{merged_by} for merging it ๐ŸŒฎ๐ŸŽ‰." \
28-
f"I'm working now to backport this PR to: {', '.join(branches)}."
29-
util.comment_on_pr(issue_number, message)
30-
31-
for branch in branches:
32-
tasks.backport_task.delay(commit_hash,
33-
branch,
34-
issue_number=issue_number,
35-
created_by=created_by,
36-
merged_by=merged_by)
24+
branches = [label['name'].split()[-1]
25+
for label in pr_labels
26+
if label['name'].startswith("needs backport to")]
27+
28+
if branches:
29+
message = "๐Ÿ๐Ÿ’โ›๐Ÿค– " \
30+
f"Thanks @{created_by} for the PR, and @{merged_by} for merging it ๐ŸŒฎ๐ŸŽ‰." \
31+
f"I'm working now to backport this PR to: {', '.join(branches)}."
32+
util.comment_on_pr(issue_number, message)
33+
34+
for branch in branches:
35+
tasks.backport_task.delay(commit_hash,
36+
branch,
37+
issue_number=issue_number,
38+
created_by=created_by,
39+
merged_by=merged_by)

0 commit comments

Comments
ย (0)