merge_requests.md 4.2 KB
Newer Older
V
Valeriy Sizov 已提交
1 2
## List merge requests

3 4
Get all merge requests for this project. This function takes pagination parameters
`page` and `per_page` to restrict the list of merge requests.
V
Valeriy Sizov 已提交
5 6

```
V
Valeriy Sizov 已提交
7
GET /projects/:id/merge_requests
V
Valeriy Sizov 已提交
8 9 10 11
```

Parameters:

12
+ `id` (required) - The ID of a project
V
Valeriy Sizov 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25

```json
[
    {
        "id":1,
        "target_branch":"master",
        "source_branch":"test1",
        "project_id":3,
        "title":"test1",
        "closed":true,
        "merged":false,
        "author":{
            "id":1,
26
            "username": "admin",
V
Valeriy Sizov 已提交
27 28 29 30 31 32 33
            "email":"admin@local.host",
            "name":"Administrator",
            "blocked":false,
            "created_at":"2012-04-29T08:46:00Z"
        },
        "assignee":{
            "id":1,
34
            "username": "admin",
V
Valeriy Sizov 已提交
35 36 37 38 39 40 41 42 43
            "email":"admin@local.host",
            "name":"Administrator",
            "blocked":false,
            "created_at":"2012-04-29T08:46:00Z"
        }
    }
]
```

44 45 46 47

## Get single MR

Shows information about a single merge request.
V
Valeriy Sizov 已提交
48 49

```
V
Valeriy Sizov 已提交
50
GET /projects/:id/merge_request/:merge_request_id
V
Valeriy Sizov 已提交
51 52 53 54
```

Parameters:

55
+ `id` (required) - The ID of a project
V
Valeriy Sizov 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68
+ `merge_request_id` (required) - The ID of MR

```json
{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
    "closed":true,
    "merged":false,
    "author":{
        "id":1,
69
        "username": "admin",
V
Valeriy Sizov 已提交
70 71 72 73 74 75 76
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
77
        "username": "admin",
V
Valeriy Sizov 已提交
78 79 80 81 82 83 84 85 86 87 88
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```


## Create MR

89
Creates a new merge request.
V
Valeriy Sizov 已提交
90 91

```
V
Valeriy Sizov 已提交
92
POST /projects/:id/merge_requests
V
Valeriy Sizov 已提交
93 94 95 96
```

Parameters:

97
+ `id` (required) - The ID of a project
V
Valeriy Sizov 已提交
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
+ `source_branch` (required) - The source branch
+ `target_branch` (required) - The target branch
+ `assignee_id`              - Assignee user ID
+ `title` (required)         - Title of MR

```json
{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
    "closed":true,
    "merged":false,
    "author":{
        "id":1,
114
        "username": "admin",
V
Valeriy Sizov 已提交
115 116 117 118 119 120 121
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
122
        "username": "admin",
V
Valeriy Sizov 已提交
123 124 125 126 127 128 129 130
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```

131

V
Valeriy Sizov 已提交
132 133
## Update MR

134
Updates an existing merge request. You can change branches, title, or even close the MR.
V
Valeriy Sizov 已提交
135 136

```
V
Valeriy Sizov 已提交
137
PUT /projects/:id/merge_request/:merge_request_id
V
Valeriy Sizov 已提交
138 139 140 141
```

Parameters:

142
+ `id` (required)               - The ID of a project
V
Valeriy Sizov 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
+ `merge_request_id` (required) - ID of MR
+ `source_branch`               - The source branch
+ `target_branch`               - The target branch
+ `assignee_id`                 - Assignee user ID
+ `title`                       - Title of MR
+ `closed`                      - Status of MR. true - closed


```json
{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
    "closed":true,
    "merged":false,
    "author":{
        "id":1,
162
        "username": "admin",
V
Valeriy Sizov 已提交
163 164 165 166 167 168 169
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
170
        "username": "admin",
V
Valeriy Sizov 已提交
171 172 173 174 175 176 177
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```
178 179


V
Valeriy Sizov 已提交
180 181
## Post comment to MR

182
Adds a comment to a merge request.
V
Valeriy Sizov 已提交
183 184

```
V
Valeriy Sizov 已提交
185
POST /projects/:id/merge_request/:merge_request_id/comments
V
Valeriy Sizov 已提交
186 187 188 189
```

Parameters:

190
+ `id` (required) - The ID of a project
191
+ `merge_request_id` (required) - ID of merge request
V
Valeriy Sizov 已提交
192 193 194 195 196 197 198
+ `note` (required) - Text of comment


```json
{
    "author":{
        "id":1,
199
        "username": "admin",
V
Valeriy Sizov 已提交
200 201 202 203 204 205 206 207
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    },
    "note":"text1"
}
```