[llvm] 49ad577 - [workflow] Don't fail workflow if we already have a PR for an issue
Tobias Hieta via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 07:02:44 PDT 2022
Author: Tobias Hieta
Date: 2022-05-27T16:02:39+02:00
New Revision: 49ad577c0772be38f6691f93c7ac1b5dbb4dc9bf
URL: https://github.com/llvm/llvm-project/commit/49ad577c0772be38f6691f93c7ac1b5dbb4dc9bf
DIFF: https://github.com/llvm/llvm-project/commit/49ad577c0772be38f6691f93c7ac1b5dbb4dc9bf.diff
LOG: [workflow] Don't fail workflow if we already have a PR for an issue
When running /cherry-pick several times you will get an
error when it tries to create a new PR since there already
is one.
This checks if we have PR first.
Fixes #54862
Reviewed By: tstellar
Differential Revision: https://reviews.llvm.org/D123657
Added:
Modified:
llvm/utils/git/github-automation.py
Removed:
################################################################################
diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index 7dbcf02a820b6..e094fe810f997 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -191,6 +191,9 @@ def create_branch(self, commits:List[str]) -> bool:
self.issue_remove_cherry_pick_failed_label()
return True
+ def check_if_pull_request_exists(self, repo:github.Repository.Repository, head:str) -> bool:
+ pulls = repo.get_pulls(head=head)
+ return pulls != None
def create_pull_request(self, owner:str, branch:str) -> bool:
"""
@@ -208,11 +211,15 @@ def create_pull_request(self, owner:str, branch:str) -> bool:
release_branch_for_issue = self.release_branch_for_issue
if release_branch_for_issue is None:
return False
+ head = f"{owner}:{branch}"
+ if self.check_if_pull_request_exists(repo, head):
+ print("PR already exists...")
+ return True
try:
- pull = repo.create_pull(title='PR for {}'.format(issue_ref),
+ pull = repo.create_pull(title=f"PR for {issue_ref}",
body='resolves {}'.format(issue_ref),
base=release_branch_for_issue,
- head='{}:{}'.format(owner, branch),
+ head=head,
maintainer_can_modify=False)
except Exception as e:
self.issue_notify_pull_request_failure(branch)
More information about the llvm-commits
mailing list