Pygithub: 没有对 PullRequest 返回的评论

创建于 2012-08-21  ·  7评论  ·  资料来源: PyGithub/PyGithub

你好,问题来了。
没有评论返回。 但评论计数显示出适当的价值。

p = z.pulls[1]

输出:
输出:u'\u041d\u0435\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c =)'
p.comments
输出:1
p.get_comments()
输出:
列表(p.get_comments())
输出: []

有任何想法吗 ?

bug feature request

所有7条评论

你好!

我确认以下代码存在相同的问题:

import github

g = github.Github()
r = g.get_user( "jacquev6" ).get_repo( "PyGithub" )
p = r.get_pull( 57 )
print p.title, "has", p.comments, "comments"
print [ c.body[ :15 ] for c in p.get_comments() ]

它打印:

Allows connection to GitHub Enterprise installs on local URLs has 2 comments
[]

最后一行调用 API https://api.github.com/repos/jacquev6/PyGithub/pulls/57/comments ,如http://developer.github.com/v3/pulls/comments/#list -comments 中所述-on-a-pull-request,但 API 返回一个空列表。 我只是通过调用https://api.github.com/repos/jacquev6/PyGithub/issues/57/comments来获得评论。 问题必须在 Github 一方。

作为临时解决方法,您可以使用以下代码将拉取请求视为问题,然后调用其他 API:

print [ c.body[ :15 ] for c in r.get_issue( p.number ).get_comments() ]

目前,我没有足够的时间来处理这个问题,但如果它在 9 月初仍然存在,我会联系 Github 和/或补丁 PyGithub。

享受,

为了稍微改进解决方法,您可以这样做以确定问题是否是 PR(因为所有 PR 也是问题):

        if myIssue.pull_request.diff_url:
            PR=True
        else:
            PR=False

谢谢! 将使用此作为解决方法。

我刚刚就这个问题联系了 Github。

这是我从 Github 收到的回复:

From: Wynn Netherland
Subject: API v3, list comments on pull requests

Hi, Vincent. I know it's confusing but we actually have three types of comments on GitHub, so there are
three different spots in the API to grab them. Be sure you're looking in the right spot for the data you expect.

Pull Request comments are the top-level comments found on the Pull Request page. These are retrieved via
the Issues API [1] since PRs are essentially specialized Issues. Pull Request review comments are those made
against the diff on the PR. You can grab these with the Review Comments API [2]. Finally, line comments made
outside the context of a PR on a raw commit can be retrieved via the Commit Comments API [3].

Armed with that info, let me know if you're not seeing the data you expect and the API call you're making, and I
can dig a bit deeper.

[1] http://developer.github.com/v3/issues/comments/
[2] http://developer.github.com/v3/pulls/comments/
[3] http://developer.github.com/v3/repos/comments/

Cheers,

因此,这与我们在此处看到的内容一致: https : PullRequest.get_comments使用 Pull Requests API。 @nixoz2k7是否也与您的原始问题一致?

无论如何,这是一种误导,所以我将添加两个名为get_issue_comments (使用问题 API)和get_review_commentsget_comments同义词,使用 Pull Requests API)的方法。 预计下周中旬会出现这种情况。

我刚刚在https://github.com/jacquev6/PyGithub/tree/develop上推送了新方法@nixoz2k7 ,如果您对所说内容仍有

非常感谢 ;)
顺便说一句,它适用于“问题”解决方法。 已经稳定了 2 周。

再次感谢你。
谢尔盖。

此页面是否有帮助?
0 / 5 - 0 等级