github api以及如何获取代码片段和评论拉
问题描述:
我想使用github api来生成报告,我可以看到在拉请求中更新的代码以及与其相关的注释。我已经看过了事件时间,和注释端点,并拉入请求diff_url,但似乎无法在一起得到的信息就像在一个随机拉动请求这个jQuery事件/转换项:github api以及如何获取代码片段和评论拉
我甚至不需要漂亮的添加/删除阴影,文字很好。我可以从pull请求中获取diff_url,它显示了所有依次列出的文件中的所有代码更改,但无法通过评论“这里应该有一个换行符”来获取此特定视图。以及它所指的代码。
任何见解非常感谢!
答
我联系了github支持,并再次得到了他们的支持!
(谢谢!)。 '这是你怎么做'< - 唱调...
是的,你可以通过API获取代码段和评论。什么你要找的是在这里:
https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
如果你取的是,“body
”现场会给你意见的内容和“diff_hunk
”现场会给你片断的评论是(“path
”字段告诉你代码片段来自哪个文件)。
例子:注意此评论:
https://github.com/github/linguist/pull/3820/files#r143359135
这里的API在注释:相关领域
https://api.github.com/repos/github/linguist/pulls/comments/143359135
和:
"body": "https://github.com/github/linguist/pull/3638
attempted to include support for the `.k` extension too,
which would have posed a problem due to *ing with non-Kdb,
yet undefined, languages.
This PR doesn't mention that extension at all.
Whilst this isn't a problem, is `.q` the preferred extension for
Q/Kdb+?\r\n\r\nI
notice that https://github.com/KxSystems/kdb which you reference
includes `.k` files which won't be recognised as Q/Kdb+ once
this PR has been merged, hence the question.",
"path": "lib/linguist/languages.yml",
"diff_hunk": "@@ -3601,6 +3601,18 @@ Python traceback:\n
tm_scope: text.python.traceback\n
ace_mode: text\n
language_id: 304\n+Q:\n+
type: programming\n+
color: \"#0040CD\"\n+
aliases:\n+ -Kdb+\n+
extensions:\n+ - \".q\"",
这一点,再加与实际回报根据需要从函数中获取值并格式化模板将完成工作。
我已经尝试了一个似乎可以工作的卷曲,但是无法从我的python中得到它的工作,即使(我认为是)正确的Accept头部。我使用的卷曲模式是: curl -u“username:password”-H“Accept:application/vnd.github.v3 + .html + json”https://api.github.com/repos/repo-所有者/回购 - 名称/拉/拉 - #/评论 我得到的输出,显示一个diff_hunk与评论和审查 - 完美。但不会与使用python的代码一起飞行: requests.get(get_url,auth =(self.username,self.password),headers = headers) – campana