[PATCH] D123657: [workflow] Don't fail workflow if we already have a PR for an issue

Tobias Hieta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 14 00:20:17 PDT 2022


thieta updated this revision to Diff 422755.
thieta marked an inline comment as done.
thieta added a comment.

Remove unused parameter


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123657/new/

https://reviews.llvm.org/D123657

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
@@ -191,6 +191,9 @@
         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 @@
         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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123657.422755.patch
Type: text/x-patch
Size: 1440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220414/a64e99df/attachment.bin>


More information about the llvm-commits mailing list