diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py --- a/llvm/utils/git/github-automation.py +++ b/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