2017-10-09 170 views
2

我想使用github api來生成報告,我可以看到在拉請求中更新的代碼以及與其相關的註釋。我已經看過了事件時間,和註釋端點,並拉入請求diff_url,但似乎無法在一起得到的信息就像在一個隨機拉動請求這個jQuery事件/轉換項:github api以及如何獲取代碼片段和評論拉

Code Snippet with associated review comment

我甚至不需要漂​​亮的添加/刪除陰影,文字很好。我可以從pull請求中獲取diff_url,它顯示了所有依次列出的文件中的所有代碼更改,但無法通過評論「這裏應該有一個換行符」來獲取此特定視圖。以及它所指的代碼。

任何見解非常感謝!

+0

我已經嘗試了一個似乎可以工作的捲曲,但是無法從我的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

回答

2

我聯繫了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 clashing 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\"", 

這一點,再加與實際回報根據需要從函數中獲取值並格式化模板將完成工作。