================
@@ -124,133 +96,260 @@ def create_comment_text(warning: str, cpp_files: 
List[str]) -> str:
 
 <details>
 <summary>
-View the output from clang-tidy here.
+View the output from {self.name} here.
 </summary>
 
 ```
-{warning}
+{linter_output}
 ```
 
 </details>
 """
 
+    # TODO: Refactor this
+    def find_comment(self, pr: any) -> any:
+        all_linter_names = list(map(attrgetter("name"), ALL_LINTERS))
+        other_linter_names = [name for name in all_linter_names if name != 
self.name]
+
+        other_tags = [
+            self.COMMENT_TAG.format(linter=name) for name in other_linter_names
+        ]
+
+        for comment in pr.as_issue().get_comments():
+            body = comment.body
+            if self.comment_tag in body and not any(
+                other_tag in body for other_tag in other_tags
+            ):
+                return comment
+        return None
 
-def find_comment(pr: any) -> any:
-    for comment in pr.as_issue().get_comments():
-        if COMMENT_TAG in comment.body:
-            return comment
-    return None
+    def update_pr(self, comment_text: str, args: LintArgs, create_new: bool) 
-> None:
+        import github
+        from github import IssueComment, PullRequest
 
+        repo = github.Github(args.token).get_repo(args.repo)
+        pr = repo.get_issue(args.issue_number).as_pull_request()
 
-def create_comment(
-    comment_text: str, args: LintArgs, create_new: bool
-) -> Optional[dict]:
-    import github
+        comment_text = self.comment_tag + "\n\n" + comment_text
----------------
EugeneZelenko wrote:

```suggestion
        comment_text = f"{self.comment_tag}\n\n{comment_text}"
```

https://github.com/llvm/llvm-project/pull/168827
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to