Protects a single project repository branch. This is an idempotent function, protecting an already
Protects a single project repository branch. This is an idempotent function,
protected repository branch still returns a `200 OK` status code.
protecting an already protected repository branch still returns a `200 OK`
status code.
```
```
PUT /projects/:id/repository/branches/:branch/protect
PUT /projects/:id/repository/branches/:branch/protect
```
```
Parameters:
```bash
curl -X PUT -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/repository/branches/master/protect
```
-`id` (required) - The ID of a project
| Attribute | Type | Required | Description |
-`branch` (required) - The name of the branch
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `branch` | string | yes | The name of the branch |
Example response:
```json
```json
{
{
...
@@ -103,17 +123,24 @@ Parameters:
...
@@ -103,17 +123,24 @@ Parameters:
## Unprotect repository branch
## Unprotect repository branch
Unprotects a single project repository branch. This is an idempotent function, unprotecting an already
Unprotects a single project repository branch. This is an idempotent function,
unprotected repository branch still returns a `200 OK` status code.
unprotecting an already unprotected repository branch still returns a `200 OK`
status code.
```
```
PUT /projects/:id/repository/branches/:branch/unprotect
PUT /projects/:id/repository/branches/:branch/unprotect
```
```
Parameters:
```bash
curl -X PUT -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/repository/branches/master/unprotect
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `branch` | string | yes | The name of the branch |
-`id` (required) - The ID of a project
Example response:
-`branch` (required) - The name of the branch
```json
```json
{
{
...
@@ -141,11 +168,17 @@ Parameters:
...
@@ -141,11 +168,17 @@ Parameters:
POST /projects/:id/repository/branches
POST /projects/:id/repository/branches
```
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `branch_name` | string | yes | The name of the branch |
| `ref` | string | yes | The branch name or commit SHA to create branch from |
```bash
curl -X POST -H"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK""https://gitlab.example.com/api/v3/projects/5/repository/branches?branch_name=newbranch&ref=master"
```
-`id` (required) - The ID of a project
Example response:
-`branch_name` (required) - The name of the branch
-`ref` (required) - Create branch from commit SHA or existing branch
```json
```json
{
{
...
@@ -162,12 +195,13 @@ Parameters:
...
@@ -162,12 +195,13 @@ Parameters:
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
]
]
},
},
"name":"master",
"name":"newbranch",
"protected":false
"protected":false
}
}
```
```
It return 200 if succeed or 400 if failed with error message explaining reason.
It returns `200` if it succeeds or `400` if failed with an error message
explaining the reason.
## Delete repository branch
## Delete repository branch
...
@@ -175,18 +209,22 @@ It return 200 if succeed or 400 if failed with error message explaining reason.
...
@@ -175,18 +209,22 @@ It return 200 if succeed or 400 if failed with error message explaining reason.
DELETE /projects/:id/repository/branches/:branch
DELETE /projects/:id/repository/branches/:branch
```
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `branch` | string | yes | The name of the branch |
-`id` (required) - The ID of a project
It returns `200` if it succeeds, `404` if the branch to be deleted does not exist
-`branch` (required) - The name of the branch
or `400` for other reasons. In case of an error, an explaining message is provided.
It return 200 if succeed, 404 if the branch to be deleted does not exist
```bash
or 400 for other reasons. In case of an error, an explaining message is provided.