[PATCH] D126940: github: Fix release automation /branch command with new repo

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 20:00:52 PDT 2022


tstellar updated this revision to Diff 443122.
tstellar added a comment.

Address some review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126940/new/

https://reviews.llvm.org/D126940

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
@@ -339,7 +339,18 @@
         release_branch_for_issue = self.release_branch_for_issue
         if release_branch_for_issue is None:
             return False
-        head = f"{owner}:{branch}"
+        head_branch = branch
+        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
+            # requests on forked repos.
+            head_branch = f'{owner}-{branch}'
+            local_repo = Repo(self.llvm_project_dir)
+            local_repo.git.fetch(f'https://github.com/{owner}/llvm-project', f'{branch}:{branch}')
+            local_repo.git.push(self.push_url, f'{branch}:{head_branch}', force=True)
+            owner = repo.owner.login
+
+        head = f"{owner}:{head_branch}"
         if self.check_if_pull_request_exists(repo, head):
             print("PR already exists...")
             return True


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126940.443122.patch
Type: text/x-patch
Size: 1147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220708/827db9ed/attachment.bin>


More information about the llvm-commits mailing list