Recentemente, movemos algumas das documentações da API REST. Se você não conseguir encontrar o que está procurando, tente as novas páginas da API REST Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks}.
Comentários de commit
Use a API REST para interagir com comentários de commits.
Sobre os comentários de um commit
É possível criar, editar e exibir comentários de commits usando a API REST. Um comentário de commit é um comentário feito em um commit específico. Para obter mais informações, confira "Trabalhar com comentários".
Tipos de mídia personalizados para comentários de commit
Estes são os tipos de mídia compatíveis com os comentários do commit. Leia mais sobre o uso de tipos de mídia na API aqui.
application/vnd.github-commitcomment.raw+json
application/vnd.github-commitcomment.text+json
application/vnd.github-commitcomment.html+json
application/vnd.github-commitcomment.full+json
Para obter mais informações, confira "Tipos de mídia".
List commit comments for a repository
Commit Comments use these custom media types. You can read more about the use of media types in the API here.
Comments are ordered by ascending ID.
Parâmetros para "List commit comments for a repository"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
Parâmetros de consulta |
Name, Tipo, Descrição |
per_page integer The number of results per page (max 100). Padrão: |
page integer Page number of the results to fetch. Padrão: |
Códigos de status de resposta HTTP para "List commit comments for a repository"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List commit comments for a repository"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/comments
Response
Status: 200
[
{
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
"url": "https://api.github.com/repos/octocat/Hello-World/comments/1",
"id": 1,
"node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
"body": "Great stuff",
"path": "file1.txt",
"position": 4,
"line": 14,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z",
"author_association": "COLLABORATOR"
}
]
Get a commit comment
Parâmetros para "Get a commit comment"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
comment_id integer ObrigatórioThe unique identifier of the comment. |
Códigos de status de resposta HTTP para "Get a commit comment"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Exemplos de código para "Get a commit comment"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID
Response
Status: 200
{
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
"url": "https://api.github.com/repos/octocat/Hello-World/comments/1",
"id": 1,
"node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
"body": "Great stuff",
"path": "file1.txt",
"position": 4,
"line": 14,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author_association": "COLLABORATOR",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
Update a commit comment
Parâmetros para "Update a commit comment"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
comment_id integer ObrigatórioThe unique identifier of the comment. |
Parâmetros do corpo |
Name, Tipo, Descrição |
body string ObrigatórioThe contents of the comment |
Códigos de status de resposta HTTP para "Update a commit comment"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Exemplos de código para "Update a commit comment"
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID \
-d '{"body":"Nice change"}'
Response
Status: 200
{
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
"url": "https://api.github.com/repos/octocat/Hello-World/comments/1",
"id": 1,
"node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
"body": "Nice change",
"path": "file1.txt",
"position": 4,
"line": 14,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author_association": "COLLABORATOR",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}
Delete a commit comment
Parâmetros para "Delete a commit comment"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
comment_id integer ObrigatórioThe unique identifier of the comment. |
Códigos de status de resposta HTTP para "Delete a commit comment"
Código de status | Descrição |
---|---|
204 | No Content |
404 | Resource not found |
Exemplos de código para "Delete a commit comment"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/comments/COMMENT_ID
Response
Status: 204
List commit comments
Use the :commit_sha
to specify the commit that will have its comments listed.
Parâmetros para "List commit comments"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
commit_sha string ObrigatórioThe SHA of the commit. |
Parâmetros de consulta |
Name, Tipo, Descrição |
per_page integer The number of results per page (max 100). Padrão: |
page integer Page number of the results to fetch. Padrão: |
Códigos de status de resposta HTTP para "List commit comments"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List commit comments"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/commits/COMMIT_SHA/comments
Response
Status: 200
[
{
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
"url": "https://api.github.com/repos/octocat/Hello-World/comments/1",
"id": 1,
"node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
"body": "Great stuff",
"path": "file1.txt",
"position": 4,
"line": 14,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z",
"author_association": "COLLABORATOR"
}
]
Create a commit comment
Create a comment for a commit using its :commit_sha
.
This endpoint triggers notifications. Creating content too quickly using this endpoint may result in secondary rate limiting. See "Secondary rate limits" and "Dealing with secondary rate limits" for details.
Parâmetros para "Create a commit comment"
Cabeçalhos |
---|
Name, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Name, Tipo, Descrição |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository. The name is not case sensitive. |
commit_sha string ObrigatórioThe SHA of the commit. |
Parâmetros do corpo |
Name, Tipo, Descrição |
body string ObrigatórioThe contents of the comment. |
path string Relative path of the file to comment on. |
position integer Line index in the diff to comment on. |
line integer Deprecated. Use position parameter instead. Line number in the file to comment on. |
Códigos de status de resposta HTTP para "Create a commit comment"
Código de status | Descrição |
---|---|
201 | Created |
403 | Forbidden |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Create a commit comment"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/repos/OWNER/REPO/commits/COMMIT_SHA/comments \
-d '{"body":"Great stuff","path":"file1.txt","position":4,"line":1}'
Response
Status: 201
{
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e#commitcomment-1",
"url": "https://api.github.com/repos/octocat/Hello-World/comments/1",
"id": 1,
"node_id": "MDEzOkNvbW1pdENvbW1lbnQx",
"body": "Great stuff",
"path": "file1.txt",
"position": 4,
"line": 14,
"commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
"author_association": "COLLABORATOR",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}