Reputation: 167
I'm trying to use the github api to generate a report where I can see the code that was updated in a pull request and the comments associated with it. I've looked at the event timeline, and the comment endpoints, and the pull request diff_url, but can't seem to get the information together like this jquery event/conversion item on a random pull request:
I don't even need the nice add/delete shading, text is fine. I can get the diff_url from the pull request which does show me all the code changes in all the file listed sequentially, but can't get this particular view with the comment "There should probably be a line break here." and the code that it is referring to.
Any insights greatly appreciated!
Upvotes: 2
Views: 1996
Reputation: 167
I contacted github support and once again got excellent support from them!
(thank you!). 'This is how you do it' <- sung in tune...
Yeah, you can get the code snippet and the comment via the API. What you're looking for is here:
https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request
If you fetch that, the "body
" field will give you the contents of the comment and the "diff_hunk
" field will give you the snippet the comment is related to (the "path
" field tells you which file the snippet is from).
Example: notice this comment:
https://github.com/github/linguist/pull/3820/files#r143359135
Here's that comment in the API:
https://api.github.com/repos/github/linguist/pulls/comments/143359135
And the relevant fields:
"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\"",
This, coupled with actually returning the value from the function and formatting the template as required, will get the job done.
Upvotes: 3