为什么从PullRequest.iter_comments()返回的请求请求中的对话注释不可用? [英] Why aren't conversation comments in a pull request being returned from PullRequest.iter_comments()?

查看:92
本文介绍了为什么从PullRequest.iter_comments()返回的请求请求中的对话注释不可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用github3 python API,并且我有这段代码:

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)

在PR的github网页上,对话"选项卡中有几条评论,文件已更改"选项卡中只有1条评论.

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.

如何列出或创建在对话"标签中创建的PR评论?

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

推荐答案

如果我没记错的话,就无法一次列出请求请求中的所有注释.也就是说,您可以在进行操作的同时使用iter_comments获得评论注释.

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.

重要的是要记住,就GitHub而言,拉取请求只是一些额外的问题.因此,要在对话标签中获取评论,您需要使用 iter_issue_comments .

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()))

这篇关于为什么从PullRequest.iter_comments()返回的请求请求中的对话注释不可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆