[llvm] de917dc - [workflow] Don't add a comment when the first run of the formatter passes (#86335)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 15:04:14 PDT 2024


Author: Tom Stellard
Date: 2024-03-25T15:04:11-07:00
New Revision: de917dc20ece9f23eaefe5354bbc9ca194ce7555

URL: https://github.com/llvm/llvm-project/commit/de917dc20ece9f23eaefe5354bbc9ca194ce7555
DIFF: https://github.com/llvm/llvm-project/commit/de917dc20ece9f23eaefe5354bbc9ca194ce7555.diff

LOG:  [workflow] Don't add a comment when the first run of the formatter passes (#86335)

This was inadvertently changed in
2120f574103c487787390263b3692c4b167f6bdf.

Added: 
    

Modified: 
    .github/workflows/pr-code-format.yml
    llvm/utils/git/code-format-helper.py

Removed: 
    


################################################################################
diff  --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 2ed9b05cac120f..54dfe3aadbb423 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -73,7 +73,9 @@ jobs:
         # to take advantage of the new --
diff _from_common_commit option
         # explicitly in code-format-helper.py and not have to 
diff  starting at
         # the merge base.
+        # Create an empty comments file so the pr-write job doesn't fail.
         run: |
+          echo "[]" > comments &&
           python ./code-format-tools/llvm/utils/git/code-format-helper.py \
             --write-comment-to-file \
             --token ${{ secrets.GITHUB_TOKEN }} \

diff  --git a/llvm/utils/git/code-format-helper.py b/llvm/utils/git/code-format-helper.py
index af1bb3b5aec58d..f1207026704e88 100755
--- a/llvm/utils/git/code-format-helper.py
+++ b/llvm/utils/git/code-format-helper.py
@@ -124,7 +124,8 @@ def update_pr(self, comment_text: str, args: FormatArgs, create_new: bool) -> No
         existing_comment = self.find_comment(pr)
 
         if args.write_comment_to_file:
-            self.comment = {"body": comment_text}
+            if create_new or existing_comment:
+                self.comment = {"body": comment_text}
             if existing_comment:
                 self.comment["id"] = existing_comment.id
             return


        


More information about the llvm-commits mailing list