Why aren't conversation comments in a pull request being returned from PullRequest.iter_comments()?

白昼怎懂夜的黑 提交于 2020-01-25 20:40:13

问题


I am using github3 python API and I have this piece of code:

# Create new PR or get existing one
prs = [pr for pr in repo.iter_pulls(state="open", base="master",
                                    head="rev_testrev2")]
if len(prs) > 0:
    pr = prs[0]
else:
    pr = repo.create_pull("My pull request", "master", "rev_testrev2",
                          "This is a test pull request")
comments = [c for c in pr.iter_comments()]
print str(comments)

In the PR, in github web page, I have several comments in the "conversation" tab and just 1 in "Files Changed" tab.

The code above only prints the comments made in the "Files Changed" tab, which are associated with a file changed on a commit.

How do I list or create a PR comment created in the "Conversation" tab?


回答1:


You can't list all of the comments on a Pull Request at once if I remember correctly. That said, you can get review comments with iter_comments as you're already doing.

It's important to keep in mind that as far as GitHub is concerned, pull requests are just issues with a little extra on top. So to get the comments in the conversation tab, you need to use iter_issue_comments.

print(list(pr.iter_issue_comments()))


来源:https://stackoverflow.com/questions/31325449/why-arent-conversation-comments-in-a-pull-request-being-returned-from-pullreque

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!