[PATCH] D158276: [llvm][github] Allow `/` in branches name in the `/branch` command

Corentin Jabot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 06:31:11 PDT 2023


cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

IE cor3ntin/llvm-project/cor3ntin/foo


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158276

Files:
  llvm/utils/git/github-automation.py


Index: llvm/utils/git/github-automation.py
===================================================================
--- llvm/utils/git/github-automation.py
+++ llvm/utils/git/github-automation.py
@@ -385,7 +385,7 @@
 
     def create_pull_request(self, owner: str, repo_name: str, branch: str) -> bool:
         """
-        reate a pull request in `self.branch_repo_name`.  The base branch of the
+        Create a pull request in `self.branch_repo_name`.  The base branch of the
         pull request will be chosen based on the the milestone attached to
         the issue represented by `self.issue_number`  For example if the milestone
         is Release 13.0.1, then the base branch will be release/13.x. `branch`
@@ -399,7 +399,8 @@
         release_branch_for_issue = self.release_branch_for_issue
         if release_branch_for_issue is None:
             return False
-        head_branch = branch
+        local_name = branch.replace("/", "_")
+        head_branch = local_name
         if not repo.fork:
             # If the target repo is not a fork of llvm-project, we need to copy
             # the branch into the target repo.  GitHub only supports cross-repo pull
@@ -410,10 +411,10 @@
             for _ in range(0, 5):
                 try:
                     local_repo.git.fetch(
-                        f"https://github.com/{owner}/{repo_name}", f"{branch}:{branch}"
+                        f"https://github.com/{owner}/{repo_name}", f"{branch}:{local_name}"
                     )
                     local_repo.git.push(
-                        self.push_url, f"{branch}:{head_branch}", force=True
+                        self.push_url, f"{local_name}:{head_branch}", force=True
                     )
                     push_done = True
                     break


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158276.551488.patch
Type: text/x-patch
Size: 1796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/c4315391/attachment.bin>


More information about the llvm-commits mailing list