@@ -343,6 +343,7 @@ def __init__(
343
343
branch_repo_name : str ,
344
344
branch_repo_token : str ,
345
345
llvm_project_dir : str ,
346
+ requested_by : str ,
346
347
) -> None :
347
348
self ._token = token
348
349
self ._repo_name = repo
@@ -353,6 +354,7 @@ def __init__(
353
354
else :
354
355
self ._branch_repo_token = self .token
355
356
self ._llvm_project_dir = llvm_project_dir
357
+ self ._requested_by = requested_by
356
358
357
359
@property
358
360
def token (self ) -> str :
@@ -382,6 +384,10 @@ def branch_repo_token(self) -> str:
382
384
def llvm_project_dir (self ) -> str :
383
385
return self ._llvm_project_dir
384
386
387
+ @property
388
+ def requested_by (self ) -> str :
389
+ return self ._requested_by
390
+
385
391
@property
386
392
def repo (self ) -> github .Repository .Repository :
387
393
return github .Github (self .token ).get_repo (self .repo_name )
@@ -536,7 +542,7 @@ def create_branch(self, commits: List[str]) -> bool:
536
542
537
543
self .issue_remove_cherry_pick_failed_label ()
538
544
return self .create_pull_request (
539
- self .branch_repo_owner , self .repo_name , branch_name
545
+ self .branch_repo_owner , self .repo_name , branch_name , commits
540
546
)
541
547
542
548
def check_if_pull_request_exists (
@@ -545,7 +551,9 @@ def check_if_pull_request_exists(
545
551
pulls = repo .get_pulls (head = head )
546
552
return pulls .totalCount != 0
547
553
548
- def create_pull_request (self , owner : str , repo_name : str , branch : str ) -> bool :
554
+ def create_pull_request (
555
+ self , owner : str , repo_name : str , branch : str , commits : List [str ]
556
+ ) -> bool :
549
557
"""
550
558
Create a pull request in `self.repo_name`. The base branch of the
551
559
pull request will be chosen based on the the milestone attached to
@@ -567,9 +575,15 @@ def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
567
575
print ("PR already exists..." )
568
576
return True
569
577
try :
578
+ commit_message = repo .get_commit (commits [- 1 ]).commit .message
579
+ message_lines = commit_message .splitlines ()
580
+ title = "{}: {}" .format (release_branch_for_issue , message_lines [0 ])
581
+ body = "Backport {}\n \n Requested by: @{}" .format (
582
+ " " .join (commits ), self .requested_by
583
+ )
570
584
pull = repo .create_pull (
571
- title = f"PR for { issue_ref } " ,
572
- body = "resolves {}" . format ( issue_ref ) ,
585
+ title = title ,
586
+ body = body ,
573
587
base = release_branch_for_issue ,
574
588
head = head ,
575
589
maintainer_can_modify = False ,
@@ -683,6 +697,12 @@ def execute_command(self) -> bool:
683
697
"setup-llvmbot-git" ,
684
698
help = "Set the default user and email for the git repo in LLVM_PROJECT_DIR to llvmbot" ,
685
699
)
700
+ release_workflow_parser .add_argument (
701
+ "--requested-by" ,
702
+ type = str ,
703
+ required = True ,
704
+ help = "The user that requested this backport" ,
705
+ )
686
706
687
707
args = parser .parse_args ()
688
708
@@ -712,6 +732,7 @@ def execute_command(self) -> bool:
712
732
args .branch_repo ,
713
733
args .branch_repo_token ,
714
734
args .llvm_project_dir ,
735
+ args .requested_by ,
715
736
)
716
737
if not release_workflow .release_branch_for_issue :
717
738
release_workflow .issue_notify_no_milestone (sys .stdin .readlines ())
0 commit comments