Delete redundant LABEL_ prefix

This commit is contained in:
Mikhail f. Shiryaev 2022-09-16 10:23:49 +02:00
parent ab7bd95d8b
commit 6a17d4e705
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -44,11 +44,11 @@ from ssh import SSHKey
class Labels: class Labels:
LABEL_MUST_BACKPORT = "pr-must-backport" MUST_BACKPORT = "pr-must-backport"
LABEL_BACKPORT = "pr-backport" BACKPORT = "pr-backport"
LABEL_BACKPORTS_CREATED = "pr-backports-created" BACKPORTS_CREATED = "pr-backports-created"
LABEL_CHERRYPICK = "pr-cherrypick" CHERRYPICK = "pr-cherrypick"
LABEL_DO_NOT_TEST = "do not test" DO_NOT_TEST = "do not test"
class ReleaseBranch: class ReleaseBranch:
@ -204,8 +204,8 @@ Merge it only if you intend to backport changes to the target branch, otherwise
base=self.backport_branch, base=self.backport_branch,
head=self.cherrypick_branch, head=self.cherrypick_branch,
) )
self.cherrypick_pr.add_to_labels(Labels.LABEL_CHERRYPICK) self.cherrypick_pr.add_to_labels(Labels.CHERRYPICK)
self.cherrypick_pr.add_to_labels(Labels.LABEL_DO_NOT_TEST) self.cherrypick_pr.add_to_labels(Labels.DO_NOT_TEST)
self._assign_new_pr(self.cherrypick_pr) self._assign_new_pr(self.cherrypick_pr)
def create_backport(self): def create_backport(self):
@ -236,7 +236,7 @@ Merge it only if you intend to backport changes to the target branch, otherwise
base=self.name, base=self.name,
head=self.backport_branch, head=self.backport_branch,
) )
self.backport_pr.add_to_labels(Labels.LABEL_BACKPORT) self.backport_pr.add_to_labels(Labels.BACKPORT)
self._assign_new_pr(self.backport_pr) self._assign_new_pr(self.backport_pr)
def _assign_new_pr(self, new_pr: PullRequest): def _assign_new_pr(self, new_pr: PullRequest):
@ -321,8 +321,8 @@ class Backport:
tomorrow = date.today() + timedelta(days=1) tomorrow = date.today() + timedelta(days=1)
logging.info("Receive PRs suppose to be backported") logging.info("Receive PRs suppose to be backported")
self.prs_for_backport = self.gh.get_pulls_from_search( self.prs_for_backport = self.gh.get_pulls_from_search(
query=f"{self._query} -label:{Labels.LABEL_BACKPORTS_CREATED}", query=f"{self._query} -label:{Labels.BACKPORTS_CREATED}",
label=",".join(self.labels_to_backport + [Labels.LABEL_MUST_BACKPORT]), label=",".join(self.labels_to_backport + [Labels.MUST_BACKPORT]),
merged=[since_date, tomorrow], merged=[since_date, tomorrow],
) )
logging.info( logging.info(
@ -342,7 +342,7 @@ class Backport:
def process_pr(self, pr: PullRequest): def process_pr(self, pr: PullRequest):
pr_labels = [label.name for label in pr.labels] pr_labels = [label.name for label in pr.labels]
if Labels.LABEL_MUST_BACKPORT in pr_labels: if Labels.MUST_BACKPORT in pr_labels:
branches = [ branches = [
ReleaseBranch(br, pr) for br in self.release_branches ReleaseBranch(br, pr) for br in self.release_branches
] # type: List[ReleaseBranch] ] # type: List[ReleaseBranch]
@ -407,11 +407,11 @@ class Backport:
if self.dry_run: if self.dry_run:
logging.info("DRY RUN: would mark PR #%s as done", pr.number) logging.info("DRY RUN: would mark PR #%s as done", pr.number)
return return
pr.add_to_labels(Labels.LABEL_BACKPORTS_CREATED) pr.add_to_labels(Labels.BACKPORTS_CREATED)
logging.info( logging.info(
"PR #%s is successfully labeled with `%s`", "PR #%s is successfully labeled with `%s`",
pr.number, pr.number,
Labels.LABEL_BACKPORTS_CREATED, Labels.BACKPORTS_CREATED,
) )
@property @property