@@ -444,7 +444,7 @@ def issue_notify_branch(self) -> None:
444
444
445
445
def issue_notify_pull_request (self , pull : github .PullRequest .PullRequest ) -> None :
446
446
self .issue .create_comment (
447
- "/pull-request {}#{}" .format (self .branch_repo_name , pull .number )
447
+ "/pull-request {}#{}" .format (self .repo_name , pull .number )
448
448
)
449
449
450
450
def make_ignore_comment (self , comment : str ) -> str :
@@ -496,29 +496,39 @@ def issue_remove_cherry_pick_failed_label(self):
496
496
if self .CHERRY_PICK_FAILED_LABEL in [l .name for l in self .issue .labels ]:
497
497
self .issue .remove_from_labels (self .CHERRY_PICK_FAILED_LABEL )
498
498
499
+ def get_main_commit (self , cherry_pick_sha : str ) -> github .Commit .Commit :
500
+ commit = self .repo .get_commit (cherry_pick_sha )
501
+ message = commit .commit .message
502
+ m = re .search ("\(cherry picked from commit ([0-9a-f]+)\)" , message )
503
+ if not m :
504
+ return None
505
+ return self .repo .get_commit (m .group (1 ))
506
+
499
507
def pr_request_review (self , pr : github .PullRequest .PullRequest ):
500
508
"""
501
509
This function will try to find the best reviewers for `commits` and
502
- then add a comment requesting review of the backport and assign the
503
- pull request to the selected reviewers.
510
+ then add a comment requesting review of the backport and add them as
511
+ reviewers.
504
512
505
- The reviewers selected are those users who approved the patch in
506
- Phabricator .
513
+ The reviewers selected are those users who approved the pull request
514
+ for the main branch .
507
515
"""
508
516
reviewers = []
509
517
for commit in pr .get_commits ():
510
- approvers = phab_get_commit_approvers (self .phab_token , commit )
511
- for a in approvers :
512
- login = phab_login_to_github_login (self .phab_token , self .repo , a )
513
- if not login :
514
- continue
515
- reviewers .append (login )
518
+ main_commit = self .get_main_commit (commit .sha )
519
+ if not main_commit :
520
+ continue
521
+ for pull in main_commit .get_pulls ():
522
+ for review in pull .get_reviews ():
523
+ if review .state != "APPROVED" :
524
+ continue
525
+ reviewers .append (review .user .login )
516
526
if len (reviewers ):
517
527
message = "{} What do you think about merging this PR to the release branch?" .format (
518
528
" " .join (["@" + r for r in reviewers ])
519
529
)
520
530
pr .create_issue_comment (message )
521
- pr .add_to_assignees ( * reviewers )
531
+ pr .create_review_request ( reviewers )
522
532
523
533
def create_branch (self , commits : List [str ]) -> bool :
524
534
"""
@@ -559,15 +569,15 @@ def check_if_pull_request_exists(
559
569
560
570
def create_pull_request (self , owner : str , repo_name : str , branch : str ) -> bool :
561
571
"""
562
- reate a pull request in `self.branch_repo_name `. The base branch of the
572
+ Create a pull request in `self.repo_name `. The base branch of the
563
573
pull request will be chosen based on the the milestone attached to
564
574
the issue represented by `self.issue_number` For example if the milestone
565
575
is Release 13.0.1, then the base branch will be release/13.x. `branch`
566
576
will be used as the compare branch.
567
577
https://docs.github.com/en/get-started/quickstart/github-glossary#base-branch
568
578
https://docs.github.com/en/get-started/quickstart/github-glossary#compare-branch
569
579
"""
570
- repo = github .Github (self .token ).get_repo (self .branch_repo_name )
580
+ repo = github .Github (self .token ).get_repo (self .repo_name )
571
581
issue_ref = "{}#{}" .format (self .repo_name , self .issue_number )
572
582
pull = None
573
583
release_branch_for_issue = self .release_branch_for_issue
@@ -612,9 +622,10 @@ def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
612
622
maintainer_can_modify = False ,
613
623
)
614
624
625
+ pull .as_issue ().edit (milestone = self .issue .milestone )
626
+
615
627
try :
616
- if self .phab_token :
617
- self .pr_request_review (pull )
628
+ self .pr_request_review (pull )
618
629
except Exception as e :
619
630
print ("error: Failed while searching for reviewers" , e )
620
631
@@ -710,7 +721,7 @@ def execute_command(self) -> bool:
710
721
release_workflow_parser .add_argument (
711
722
"--branch-repo" ,
712
723
type = str ,
713
- default = "llvm /llvm-project-release-prs " ,
724
+ default = "llvmbot /llvm-project" ,
714
725
help = "The name of the repo where new branches will be pushed (e.g. llvm/llvm-project)" ,
715
726
)
716
727
release_workflow_parser .add_argument (
0 commit comments