[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 Jun 2 20:12:19 PDT 2022


tstellar created this revision.
tstellar added reviewers: thieta, nikic.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a project: LLVM.

We started using the llvm/llvm-project-release-prs repo for
backport pull requests, but since this repo is not a fork of
llvm/llvm-project it will reject pull requests from other repos. In
order to fix this, when ever someone uses the /branch command to request
a branch be merged into the release branch, we first copy the branch to
the llvm-project-release-prs repo and then create the pull request.


Repository:
  rG LLVM Github Monorepo

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
@@ -314,6 +314,15 @@
         release_branch_for_issue = self.release_branch_for_issue
         if release_branch_for_issue is None:
             return False
+        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.
+            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}:{branch}', force=True)
+            owner = repo.owner.login
+
         head = f"{owner}:{branch}"
         if self.check_if_pull_request_exists(repo, head):
             print("PR already exists...")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126940.433940.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220603/6d3b88cc/attachment.bin>


More information about the llvm-commits mailing list