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

How do I obtain details from a Pull Request? #2204

Open
99Kies opened this issue Mar 20, 2022 · 3 comments
Open

How do I obtain details from a Pull Request? #2204

99Kies opened this issue Mar 20, 2022 · 3 comments

Comments

@99Kies
Copy link

99Kies commented Mar 20, 2022

How do I obtain details from a Pull Request?
such as comments.
image

@99Kies
Copy link
Author

99Kies commented Mar 20, 2022

this is my code.

repo = g.get_repo("xxx/xxxx")
for i in repo.get_pulls():
    pprint(i)
    pprint(i.body)
    pprint(i.comments)

but it can't get comments body.

@ewindels
Copy link

ewindels commented Mar 30, 2022

You can access the comments with get_comments() (https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.get_comments) for review comments and get_issue_comments() for all other comments (https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.get_issue_comments)

Example with your code:

# inside loop, i is your PullRequest object
for comment in i.get_issue_comments():
    print(comment.body)
for review_comment in i.get_comments():
    print(review_comment.body)

@watreyoung
Copy link

watreyoung commented Oct 20, 2023

You can access the comments with get_comments() (https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.get_comments) for review comments and get_issue_comments() for all other comments (https://pygithub.readthedocs.io/en/latest/github_objects/PullRequest.html#github.PullRequest.PullRequest.get_issue_comments)

Example with your code:

# inside loop, i is your PullRequest object
for comment in i.get_issue_comments():
    print(comment.body)
for review_comment in i.get_comments():
    print(review_comment.body)

It works. In fact, the results of get_issue_comments() are the same as the results that converts the pull into an issue by as_issue() and call get_comments().
In the docs, get_comments() and get_review_comments return the same results.
image
There is an another funciton that can return the review comment:get_review_comments()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants