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

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 15:09:55 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17d4796cc846: github: Fix release automation /branch command with new repo (authored by tstellar).

Changed prior to commit:
  https://reviews.llvm.org/D126940?vs=447568&id=447848#toc

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
@@ -14,6 +14,7 @@
 import os
 import re
 import sys
+import time
 from typing import *
 
 class IssueSubscriber:
@@ -224,7 +225,29 @@
         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)
+            push_done = False
+            for i in range(0,5):
+                try:
+                    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)
+                    push_done = True
+                    break
+                except Exception as e:
+                    print(e)
+                    time.sleep(30)
+                    continue
+            if not push_done:
+                raise Exception("Failed to mirror branch into {}".format(self.push_url))
+            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.447848.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/aafc3726/attachment.bin>


More information about the llvm-commits mailing list