|
| 1 | +--- |
| 2 | +title: Repo Commits API v3 | developer.github.com |
| 3 | +--- |
| 4 | + |
| 5 | +# Repo Commits API |
| 6 | + |
| 7 | +## List commits on a repository |
| 8 | + |
| 9 | + GET /repos/:user/:repo/commits |
| 10 | + |
| 11 | +### Parameters |
| 12 | + |
| 13 | +sha |
| 14 | +: _Optional_ **string** specifying the sha or branch to start listing commits |
| 15 | +from. |
| 16 | + |
| 17 | +path |
| 18 | +: _Optional_ **string** file path. Only commits containing this file |
| 19 | +will be returned. |
| 20 | + |
| 21 | +### Response |
| 22 | + |
| 23 | +<%= headers 200 %> |
| 24 | +<%= json(:commit) { |h| [h] } %> |
| 25 | + |
| 26 | +## Get a single commit |
| 27 | + |
| 28 | + GET /repos/:user/:repo/commits/:sha |
| 29 | + |
| 30 | +### Response |
| 31 | + |
| 32 | +<%= headers 200 %> |
| 33 | +<%= json(:commit) %> |
| 34 | + |
| 35 | +## List commit comments for a repository |
| 36 | + |
| 37 | + GET /repos/:user/:repo/comments |
| 38 | + |
| 39 | +### Response |
| 40 | + |
| 41 | +<%= headers 200 %> |
| 42 | +<%= json(:commit_comment) { |h| [h] } %> |
| 43 | + |
| 44 | +## List comments for a single commit |
| 45 | + |
| 46 | + GET /repos/:user/:repo/commits/:sha/comments |
| 47 | + |
| 48 | +### Response |
| 49 | + |
| 50 | +<%= headers 200 %> |
| 51 | +<%= json(:commit_comment) %> |
| 52 | + |
| 53 | +## Create a commit comment |
| 54 | + |
| 55 | + POST /repos/:user/:repo/commits/:sha/comments |
| 56 | + |
| 57 | +### Input |
| 58 | + |
| 59 | +body |
| 60 | +: _Required_ **string** for the body of the comment. |
| 61 | + |
| 62 | +commit_id |
| 63 | +: _Required_ **string** specifying the commit sha this comment was made |
| 64 | +against. |
| 65 | + |
| 66 | +line |
| 67 | +: _Required_ **number** of the line in the file where this comment is |
| 68 | +being made. |
| 69 | + |
| 70 | +path |
| 71 | +: _Required_ **string** specifying the relative path of the file that is |
| 72 | +being commented on. |
| 73 | + |
| 74 | +position |
| 75 | +: _Required_ **number** of the line index into the diff where this |
| 76 | +comment is being made. |
| 77 | + |
| 78 | +#### Example |
| 79 | + |
| 80 | +<%= json \ |
| 81 | + :body => 'Nice change', |
| 82 | + :commit_id => '6dcb09b5b57875f334f61aebed695e2e4193db5e', |
| 83 | + :line => 1, |
| 84 | + :path => 'file1.txt', |
| 85 | + :position => 4, |
| 86 | +%> |
| 87 | + |
| 88 | +### Response |
| 89 | + |
| 90 | +<%= headers 201, :Location => "https://api.github.com/user/repo/comments/1" %> |
| 91 | +<%= json :commit_comment %> |
| 92 | + |
| 93 | +## Get a single commit comment |
| 94 | + |
| 95 | + GET /repos/:user/:repo/comments/:id |
| 96 | + |
| 97 | +### Response |
| 98 | + |
| 99 | +<%= headers 200 %> |
| 100 | +<%= json :commit_comment %> |
| 101 | + |
| 102 | +## Update a commit comment |
| 103 | + |
| 104 | + PATCH /repos/:user/:repo/comments/:id |
| 105 | + |
| 106 | +### Input |
| 107 | + |
| 108 | +body |
| 109 | +: _Required_ **string** for the body of the comment. |
| 110 | + |
| 111 | +#### Example |
| 112 | + |
| 113 | +<%= json \ |
| 114 | + :body => 'Nice change' |
| 115 | +%> |
| 116 | + |
| 117 | +### Response |
| 118 | + |
| 119 | +<%= headers 200 %> |
| 120 | +<%= json :commit_comment %> |
| 121 | + |
| 122 | +## Delete a commit comment |
| 123 | + |
| 124 | + DELETE /repos/:user/:repo/comments/:id |
| 125 | + |
| 126 | +### Response |
| 127 | + |
| 128 | +<%= headers 204 %> |
| 129 | + |
0 commit comments