Adds a comment to a commit. Optionally you can post comments on a specific line
of a commit. In that case `path`, `line` and `line_type` are required.
Adds a comment to a commit.
In order to post a comment in a particular line of a particular file, you must
specify the full commit SHA, the `path`, the `line` and `line_type` should be
`new`.
The comment will be added at the end of the last commit if at least one of the
cases below is valid:
- the `sha` is instead a branch or a tag and the `line` or `path` are invalid
- the `line` number is invalid (does not exist)
- the `path` is invalid (does not exist)
In any of the above cases, the response of `line`, `line_type` and `path` is
set to `null`.
```
POST /projects/:id/repository/commits/:sha/comments
...
...
@@ -168,35 +181,33 @@ POST /projects/:id/repository/commits/:sha/comments
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `sha` | string | yes | The commit hash or name of a repository branch or tag |
| `note` | string | yes | Text of comment |
| `sha` | string | yes | The commit SHA or name of a repository branch or tag |
| `note` | string | yes | The text of the comment |
| `path` | string | no | The file path relative to the repository |
| `line` | integer | no | The line number |
| `line` | integer | no | The line number where the comment should be placed |
| `line_type` | string | no | The line type. Takes `new` or `old` as arguments |
In order to post a comment in a particular line of a particular file, you must
specify `path`, `line` and `line_type` should be `new`.
```bash
curl -X POST -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK""https://gitlab.example.com/api/v3/projects/5/repository/commits/master/comments?note=New%20comment&path=CHANGELOG&line=664&line_type=new"
curl -X POST -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"-F"note=Nice picture man\!"-F"path=dudeism.md"-F"line=11"-F"line_type=new" https://gitlab.example.com/api/v3/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/comments
-`state` (required) - The state of the status. Can be: pending, running, success, failed, canceled
-`ref` (optional) - The ref (branch or tag) to which the status refers
-`name` or `context` (optional) - The label to differentiate this status from the status of other systems. Default: "default"
-`target_url` (optional) - The target URL to associate with this status
-`description` (optional) - The short description of the status
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project
| `sha` | string | yes | The commit SHA
| `state` | string | yes | The state of the status. Can be one of the following: `pending`, `running`, `success`, `failed`, `canceled`
| `ref` | string | no | The `ref` (branch or tag) to which the status refers
| `name` or `context` | string | no | The label to differentiate this status from the status of other systems. Default value is `default`
| `target_url` | string | no | The target URL to associate with this status
| `description` | string | no | The short description of the status
```bash
curl -X POST -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK""https://gitlab.example.com/api/v3/projects/17/statuses/18f3e63d05582537db6d183d9d557be09e1f90c8?state=success"