What do the position and original_position fields mean in the github pull request comments API?
github, github-api, pull-request
Solution
You can see in "create comment"
position number Required.
The line index in the diff to comment on.
If you expand the all diff associated with the comment of PR296, you will see that the 140th line of that diff is the one commented. Go back to the last `@@` section and you will have the diff header matching that comment:
-1521,16 +1576,6 @@ Dygraph.prototype.doZoomX_ = function(lowX, highX) {
If that PR evolved (changed its modification), `original_position` should refer to the previous line index before the last change.
Problem
The github v3 API lets you list comments on a pull request via ``` curl 'https://api.github.com/repos/danvk/dygraphs/pulls/296/comments' ``` The response looks something like this: ``` [ { "id": 11908831, "diff_hunk": "@@ -1521,16 +1576,6 @@ Dygraph.prototype.doZoomX_ = function(lowX, highX) {\n };\n \n /**\n- * Transition function to use in animations. Returns values between 0.0\n- * (totally old values) and 1.0 (totally new values) for each frame.\n- * @private\n- */\n-Dygraph.zoomAnimationFunction = function(frame, numFrames) {", "path": "dygraph.js", "position": 140, "original_position": 140, "commit_id": "bacf5ce283d6871ce1c090f29bf5411341622248", "original_commit_id": "335011fd4473f55aaaceb69726d15e0063373149", "user": { ... } "body": "I'm not sure why this is showing up in the diff -- did you move it?", } ] ``` (You can see this comment on github here.) My question is: what exactly do the 140's in the "position" and "original_position" fields mean? I'd like to translate this to/from line numbers on a particular commit. The API documentation indicates that this is a line number in a unified diff, but I can't tell which unified diff it's indexing into. "dygraph.js" did not change from 335011f..bacf5ce, i.e. original_commit_id..commit_id.