2014-02-18 05:41:21 -05:00
|
|
|
# Commits API
|
|
|
|
|
|
|
|
## List repository commits
|
|
|
|
|
|
|
|
Get a list of repository commits in a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/repository/commits
|
|
|
|
```
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
| Attribute | Type | Required | Description |
|
|
|
|
| --------- | ---- | -------- | ----------- |
|
|
|
|
| `id` | integer | yes | The ID of a project |
|
|
|
|
| `ref_name` | string | no | The name of a repository branch or tag or if not given the default branch |
|
2014-02-18 05:41:21 -05:00
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
```bash
|
|
|
|
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/repository/commits"
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-02-18 05:41:21 -05:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": "ed899a2f4b50b4370feeea94676502b42383c746",
|
|
|
|
"short_id": "ed899a2f4b5",
|
|
|
|
"title": "Replace sanitize with escape once",
|
|
|
|
"author_name": "Dmitriy Zaporozhets",
|
|
|
|
"author_email": "dzaporozhets@sphereconsultinginc.com",
|
2014-07-01 15:05:29 -04:00
|
|
|
"created_at": "2012-09-20T11:50:22+03:00",
|
2015-10-26 02:26:03 -04:00
|
|
|
"message": "Replace sanitize with escape once",
|
|
|
|
"allow_failure": false
|
2014-02-18 05:41:21 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
|
|
|
|
"short_id": "6104942438c",
|
|
|
|
"title": "Sanitize for network graph",
|
|
|
|
"author_name": "randx",
|
|
|
|
"author_email": "dmitriy.zaporozhets@gmail.com",
|
2014-07-01 15:05:29 -04:00
|
|
|
"created_at": "2012-09-20T09:06:12+03:00",
|
2015-10-26 02:26:03 -04:00
|
|
|
"message": "Sanitize for network graph",
|
|
|
|
"allow_failure": false
|
2014-02-18 05:41:21 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Get a single commit
|
|
|
|
|
|
|
|
Get a specific commit identified by the commit hash or name of a branch or tag.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/repository/commits/:sha
|
|
|
|
```
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
| 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 |
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/repository/commits/master
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-02-18 05:41:21 -05:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
|
|
|
|
"short_id": "6104942438c",
|
|
|
|
"title": "Sanitize for network graph",
|
|
|
|
"author_name": "randx",
|
|
|
|
"author_email": "dmitriy.zaporozhets@gmail.com",
|
|
|
|
"created_at": "2012-09-20T09:06:12+03:00",
|
2014-07-01 15:05:29 -04:00
|
|
|
"message": "Sanitize for network graph",
|
2014-02-18 05:41:21 -05:00
|
|
|
"committed_date": "2012-09-20T09:06:12+03:00",
|
|
|
|
"authored_date": "2012-09-20T09:06:12+03:00",
|
2014-04-05 02:36:47 -04:00
|
|
|
"parent_ids": [
|
|
|
|
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
|
2015-10-06 06:01:16 -04:00
|
|
|
],
|
|
|
|
"status": "running"
|
2014-02-18 05:41:21 -05:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Get the diff of a commit
|
|
|
|
|
|
|
|
Get the diff of a commit in a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/repository/commits/:sha/diff
|
|
|
|
```
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
| 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 |
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/repository/commits/master/diff"
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-02-18 05:41:21 -05:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"diff": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files",
|
|
|
|
"new_path": "doc/update/5.4-to-6.0.md",
|
|
|
|
"old_path": "doc/update/5.4-to-6.0.md",
|
|
|
|
"a_mode": null,
|
|
|
|
"b_mode": "100644",
|
|
|
|
"new_file": false,
|
|
|
|
"renamed_file": false,
|
|
|
|
"deleted_file": false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
2014-06-27 10:48:30 -04:00
|
|
|
|
|
|
|
## Get the comments of a commit
|
|
|
|
|
|
|
|
Get the comments of a commit in a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/repository/commits/:sha/comments
|
|
|
|
```
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
| 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 |
|
|
|
|
|
|
|
|
```bash
|
|
|
|
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/repository/commits/master/comments"
|
|
|
|
```
|
|
|
|
|
|
|
|
Example response:
|
2014-06-27 10:48:30 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"note": "this code is really nice",
|
|
|
|
"author": {
|
|
|
|
"id": 11,
|
|
|
|
"username": "admin",
|
|
|
|
"email": "admin@local.host",
|
|
|
|
"name": "Administrator",
|
|
|
|
"state": "active",
|
|
|
|
"created_at": "2014-03-06T08:17:35.000Z"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Post comment to commit
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
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.
|
2014-06-27 10:48:30 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
POST /projects/:id/repository/commits/:sha/comments
|
|
|
|
```
|
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
| 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 |
|
|
|
|
| `path` | string | no | The file path relative to the repository |
|
|
|
|
| `line` | integer | no | The line number |
|
|
|
|
| `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"
|
|
|
|
```
|
2014-06-27 10:48:30 -04:00
|
|
|
|
2016-01-18 02:25:38 -05:00
|
|
|
Example response:
|
2014-06-27 10:48:30 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"author": {
|
|
|
|
"id": 1,
|
|
|
|
"username": "admin",
|
|
|
|
"email": "admin@local.host",
|
|
|
|
"name": "Administrator",
|
|
|
|
"blocked": false,
|
|
|
|
"created_at": "2012-04-29T08:46:00Z"
|
|
|
|
},
|
|
|
|
"note": "text1",
|
|
|
|
"path": "example.rb",
|
|
|
|
"line": 5,
|
|
|
|
"line_type": "new"
|
|
|
|
}
|
|
|
|
```
|
2015-10-12 06:16:00 -04:00
|
|
|
|
|
|
|
## Get the status of a commit
|
|
|
|
|
|
|
|
Get the statuses of a commit in a project.
|
|
|
|
|
|
|
|
```
|
|
|
|
GET /projects/:id/repository/commits/:sha/statuses
|
|
|
|
```
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
- `id` (required) - The ID of a project
|
|
|
|
- `sha` (required) - The commit SHA
|
|
|
|
- `ref` (optional) - Filter by ref name, it can be branch or tag
|
|
|
|
- `stage` (optional) - Filter by stage
|
|
|
|
- `name` (optional) - Filer by status name, eg. jenkins
|
|
|
|
- `all` (optional) - The flag to return all statuses, not only latest ones
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 13,
|
|
|
|
"sha": "b0b3a907f41409829b307a28b82fdbd552ee5a27",
|
|
|
|
"ref": "test",
|
|
|
|
"status": "success",
|
|
|
|
"name": "ci/jenkins",
|
|
|
|
"target_url": "http://jenkins/project/url",
|
|
|
|
"description": "Jenkins success",
|
|
|
|
"created_at": "2015-10-12T09:47:16.250Z",
|
2015-11-17 06:08:11 -05:00
|
|
|
"started_at": "2015-10-12T09:47:16.250Z",
|
2015-10-12 06:16:00 -04:00
|
|
|
"finished_at": "2015-10-12T09:47:16.262Z",
|
|
|
|
"author": {
|
|
|
|
"id": 1,
|
|
|
|
"username": "admin",
|
|
|
|
"email": "admin@local.host",
|
|
|
|
"name": "Administrator",
|
|
|
|
"blocked": false,
|
|
|
|
"created_at": "2012-04-29T08:46:00Z"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Post the status to commit
|
|
|
|
|
|
|
|
Adds or updates a status of a commit.
|
|
|
|
|
|
|
|
```
|
|
|
|
POST /projects/:id/statuses/:sha
|
|
|
|
```
|
|
|
|
|
|
|
|
- `id` (required) - The ID of a project
|
|
|
|
- `sha` (required) - The commit SHA
|
|
|
|
- `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
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"id": 13,
|
|
|
|
"sha": "b0b3a907f41409829b307a28b82fdbd552ee5a27",
|
|
|
|
"ref": "test",
|
|
|
|
"status": "success",
|
|
|
|
"name": "ci/jenkins",
|
|
|
|
"target_url": "http://jenkins/project/url",
|
|
|
|
"description": "Jenkins success",
|
|
|
|
"created_at": "2015-10-12T09:47:16.250Z",
|
2015-11-17 06:08:11 -05:00
|
|
|
"started_at": "2015-10-12T09:47:16.250Z",
|
2015-10-12 06:16:00 -04:00
|
|
|
"finished_at": "2015-10-12T09:47:16.262Z",
|
|
|
|
"author": {
|
|
|
|
"id": 1,
|
|
|
|
"username": "admin",
|
|
|
|
"email": "admin@local.host",
|
|
|
|
"name": "Administrator",
|
|
|
|
"blocked": false,
|
|
|
|
"created_at": "2012-04-29T08:46:00Z"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|