Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use pygithub to get PR comments #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,7 @@ def get_pr_author(self) -> str:

def get_pr_comments(self):
"""Download the PR review comments using the comfort-fade preview headers"""

def get_element(
requester: Requester, headers: dict, element: dict, completed: bool
):
return element

return PaginatedList(
get_element,
self.pull_request._requester,
self.pull_request.review_comments_url,
None,
)
return self.pull_request.get_review_comments()

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

for comment in comments:
if comment["body"] == body:
if comment.body == body:
print("Already posted, no need to update")
return

Expand Down Expand Up @@ -1240,7 +1229,10 @@ def cull_comments(pull_request: PullRequest, review, max_comments):
"""

unposted_comments = {HashableComment(**c) for c in review["comments"]}
posted_comments = {HashableComment(**c) for c in pull_request.get_pr_comments()}
posted_comments = {
HashableComment(c.body, c.line or c.original_line, c.path, c.side)
for c in pull_request.get_pr_comments()
}

review["comments"] = [
c.__dict__ for c in sorted(unposted_comments - posted_comments)
Expand Down
2 changes: 1 addition & 1 deletion post/clang_tidy_review/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
authors = [{name = "Peter Hill", email = "[email protected]"}]
license = {text = "MIT"}
dependencies = [
"PyGithub ~= 2.1",
"PyGithub ~= 2.6",
"unidiff ~= 0.6.0",
"pyyaml ~= 6.0.1",
"urllib3 ~= 2.2.1",
Expand Down