Skip to content

Commit 18f5deb

Browse files
committed
Merge pull request github#1027 from tomasbjerre/comment_on_line_pull
Describing how to determine position from file line
2 parents d49aa43 + 597de13 commit 18f5deb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

content/v3/pulls/comments.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ Name | Type | Description
6666
`path`|`string` | **Required**. The relative path of the file to comment on.
6767
`position`|`integer` | **Required**. The line index in the diff to comment on.
6868

69-
Note: When passing the `commit_id`, use the SHA of the latest commit in the pull request or your comment may appear as "outdated" if the specified `position` has been modified in a subsequent commit.
69+
{{#tip}}
7070

71+
When passing the `commit_id`, use the SHA of the latest commit in the pull request or your comment may appear as "outdated" if the specified `position` has been modified in a subsequent commit.
72+
73+
To comment on a specific line in a file, you will need to first determine the position in the diff. GitHub offers a `application/vnd.github.v3.diff` media type which you can use in a preceding request to view the pull request's diff. The diff needs to be [interpreted](https://en.wikipedia.org/wiki/Diff_utility#Unified_format) to translate from the *line in the file* to a *position in the diff*. The `position` value is the number of lines down from the first "@@" hunk header in the file you would like to comment on. The line just below the "@@" line is position 1, the next line is position 2, and so on. The position in the file's diff continues to increase through lines of whitespace and additional hunks until a new file is reached.
74+
75+
{{/tip}}
7176

7277
#### Example
7378

0 commit comments

Comments
 (0)