[PATCH] D126940: github: Fix release automation /branch command with new repo
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 22:27:47 PDT 2022
tstellar updated this revision to Diff 447568.
tstellar added a comment.
Print exception message when any fetch attempt fails.
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
@@ -15,6 +15,7 @@
import re
import requests
import sys
+import time
from typing import *
def run_graphql_query(query: str, token: str) -> dict:
@@ -323,7 +324,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.447568.patch
Type: text/x-patch
Size: 1723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220726/35c623f1/attachment.bin>
More information about the llvm-commits
mailing list