Assign to all at once, improve logging

This commit is contained in:
Mikhail f. Shiryaev 2022-08-31 13:05:40 +02:00
parent 6dfd415758
commit 187b10dec5
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -206,14 +206,7 @@ Merge it only if you intend to backport changes to the target branch, otherwise
)
self.cherrypick_pr.add_to_labels(Labels.LABEL_CHERRYPICK)
self.cherrypick_pr.add_to_labels(Labels.LABEL_DO_NOT_TEST)
if self.pr.assignees:
logging.info(
"Assing to assignees of the original PR: %s",
", ".join(user.login for user in self.pr.assignees),
)
self.cherrypick_pr.add_to_assignees(*self.pr.assignees)
logging.info("Assign to the author of the original PR: %s", self.pr.user.login)
self.cherrypick_pr.add_to_assignees(self.pr.user)
self._assign_new_pr(self.cherrypick_pr)
def create_backport(self):
# Checkout the backport branch from the remote and make all changes to
@ -244,14 +237,20 @@ Merge it only if you intend to backport changes to the target branch, otherwise
head=self.backport_branch,
)
self.backport_pr.add_to_labels(Labels.LABEL_BACKPORT)
self._assign_new_pr(self.backport_pr)
def _assign_new_pr(self, new_pr: PullRequest):
# It looks there some race when multiple .add_to_assignees are executed,
# so we'll add all at once
assignees = [self.pr.user]
if self.pr.assignees:
logging.info(
"Assing to assignees of the original PR: %s",
", ".join(user.login for user in self.pr.assignees),
)
self.cherrypick_pr.add_to_assignees(*self.pr.assignees)
logging.info("Assign to the author of the original PR: %s", self.pr.user.login)
self.backport_pr.add_to_assignees(self.pr.user)
assignees.extend(self.pr.assignees)
logging.info(
"Assing #%s to author and assignees of the original PR: %s",
new_pr.number,
", ".join(user.login for user in assignees),
)
new_pr.add_to_assignees(*assignees)
@property
def backported(self) -> bool: