Expand Up
@@ -343,6 +343,7 @@ def __init__(
branch_repo_name : str ,
branch_repo_token : str ,
llvm_project_dir : str ,
requested_by : str ,
) -> None :
self ._token = token
self ._repo_name = repo
Expand All
@@ -353,6 +354,7 @@ def __init__(
else :
self ._branch_repo_token = self .token
self ._llvm_project_dir = llvm_project_dir
self ._requested_by = requested_by
@property
def token (self ) -> str :
Expand Down
Expand Up
@@ -382,6 +384,10 @@ def branch_repo_token(self) -> str:
def llvm_project_dir (self ) -> str :
return self ._llvm_project_dir
@property
def requested_by (self ) -> str :
return self ._requested_by
@property
def repo (self ) -> github .Repository .Repository :
return github .Github (self .token ).get_repo (self .repo_name )
Expand Down
Expand Up
@@ -536,7 +542,7 @@ def create_branch(self, commits: List[str]) -> bool:
self .issue_remove_cherry_pick_failed_label ()
return self .create_pull_request (
self .branch_repo_owner , self .repo_name , branch_name
self .branch_repo_owner , self .repo_name , branch_name , commits
)
def check_if_pull_request_exists (
Expand All
@@ -545,7 +551,9 @@ def check_if_pull_request_exists(
pulls = repo .get_pulls (head = head )
return pulls .totalCount != 0
def create_pull_request (self , owner : str , repo_name : str , branch : str ) -> bool :
def create_pull_request (
self , owner : str , repo_name : str , branch : str , commits : List [str ]
) -> bool :
"""
Create a pull request in `self.repo_name`. The base branch of the
pull request will be chosen based on the the milestone attached to
Expand All
@@ -567,9 +575,15 @@ def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
print ("PR already exists..." )
return True
try :
commit_message = repo .get_commit (commits [- 1 ]).commit .message
message_lines = commit_message .splitlines ()
title = "{}: {}" .format (release_branch_for_issue , message_lines [0 ])
body = "Backport {}\n \n Requested by: @{}" .format (
" " .join (commits ), self .requested_by
)
pull = repo .create_pull (
title = f"PR for { issue_ref } " ,
body = "resolves {}" . format ( issue_ref ) ,
title = title ,
body = body ,
base = release_branch_for_issue ,
head = head ,
maintainer_can_modify = False ,
Expand Down
Expand Up
@@ -683,6 +697,12 @@ def execute_command(self) -> bool:
"setup-llvmbot-git" ,
help = "Set the default user and email for the git repo in LLVM_PROJECT_DIR to llvmbot" ,
)
release_workflow_parser .add_argument (
"--requested-by" ,
type = str ,
required = True ,
help = "The user that requested this backport" ,
)
args = parser .parse_args ()
Expand Down
Expand Up
@@ -712,6 +732,7 @@ def execute_command(self) -> bool:
args .branch_repo ,
args .branch_repo_token ,
args .llvm_project_dir ,
args .requested_by ,
)
if not release_workflow .release_branch_for_issue :
release_workflow .issue_notify_no_milestone (sys .stdin .readlines ())
Expand Down