Skip to content

Commit 187ce1c

Browse files
authored
Merge pull request #142 from Nerixyz/fix/pr-comments
fix: use pygithub to get PR comments
2 parents e005a6d + b9e7f52 commit 187ce1c

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

post/clang_tidy_review/clang_tidy_review/__init__.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,7 @@ def get_pr_author(self) -> str:
337337

338338
def get_pr_comments(self):
339339
"""Download the PR review comments using the comfort-fade preview headers"""
340-
341-
def get_element(
342-
requester: Requester, headers: dict, element: dict, completed: bool
343-
):
344-
return element
345-
346-
return PaginatedList(
347-
get_element,
348-
self.pull_request._requester,
349-
self.pull_request.review_comments_url,
350-
None,
351-
)
340+
return self.pull_request.get_review_comments()
352341

353342
def post_lgtm_comment(self, body: str):
354343
"""Post a "LGTM" comment if everything's clean, making sure not to spam"""
@@ -359,7 +348,7 @@ def post_lgtm_comment(self, body: str):
359348
comments = self.get_pr_comments()
360349

361350
for comment in comments:
362-
if comment["body"] == body:
351+
if comment.body == body:
363352
print("Already posted, no need to update")
364353
return
365354

@@ -1240,7 +1229,10 @@ def cull_comments(pull_request: PullRequest, review, max_comments):
12401229
"""
12411230

12421231
unposted_comments = {HashableComment(**c) for c in review["comments"]}
1243-
posted_comments = {HashableComment(**c) for c in pull_request.get_pr_comments()}
1232+
posted_comments = {
1233+
HashableComment(c.body, c.line or c.original_line, c.path, c.side)
1234+
for c in pull_request.get_pr_comments()
1235+
}
12441236

12451237
review["comments"] = [
12461238
c.__dict__ for c in sorted(unposted_comments - posted_comments)

post/clang_tidy_review/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "README.md"
1313
authors = [{name = "Peter Hill", email = "[email protected]"}]
1414
license = {text = "MIT"}
1515
dependencies = [
16-
"PyGithub ~= 2.1",
16+
"PyGithub ~= 2.6",
1717
"unidiff ~= 0.6.0",
1818
"pyyaml ~= 6.0.1",
1919
"urllib3 ~= 2.2.1",

0 commit comments

Comments
 (0)