Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels to backported PRs. #5567

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions scripts/backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def git_returncode(command):
previous_version_parts = previous_version.split(".")
previous_version_parts[-1] = "x"
backport_target = ".".join(previous_version_parts)
backported_label = f"backported-{backport_target}"

print(f"Will backport to {backport_target}.")

Expand Down Expand Up @@ -272,10 +273,6 @@ def should_backport_by_labels(pygithub_object):
for commit_sha, commit_title in main_commits:
print()

if commit_title in branch_commit_titles:
print(f"{commit_sha[:9]} '{commit_title}' is already in the branch.")
continue

pygithub_commit = source_repo.get_commit(sha=commit_sha)

pulls = pygithub_commit.get_pulls()
Expand All @@ -292,6 +289,19 @@ def should_backport_by_labels(pygithub_object):

pull = pulls[0]

# If a commit with the same title is already in the branch, mark the PR with
# a corresponding tag. This makes it easier to check what was backported
# when looking at the release milestone. Note that we do this before other
# checks -- maybe it was backported manually regardless of the usual
# conditions.
if commit_title in branch_commit_titles:
print(f"{commit_sha[:9]} '{commit_title}' is already in the branch.")

if backported_label not in {label.name for label in pull.labels}:
pull.add_to_labels(backported_label)

continue

# Next, we're going to look at the labels of both the PR and the linked
# issue, if any, to understand whether we should backport the fix. We have
# labels to request backport like "bug", and labels to prevent backport
Expand Down