merge_requests.md 4.25 KB
Newer Older
Valeriy Sizov's avatar
Valeriy Sizov committed
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.
Valeriy Sizov's avatar
Valeriy Sizov committed
5 6

```
7
GET /projects/:id/merge_requests
Valeriy Sizov's avatar
Valeriy Sizov committed
8 9 10 11
```

Parameters:

12
+ `id` (required) - The ID of a project
Valeriy Sizov's avatar
Valeriy Sizov committed
13 14 15 16 17

```json
[
    {
        "id":1,
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
18
        "iid":1,
Valeriy Sizov's avatar
Valeriy Sizov committed
19 20 21 22
        "target_branch":"master",
        "source_branch":"test1",
        "project_id":3,
        "title":"test1",
23
        "state":"opened",
24 25
        "upvotes":0,
        "downvotes":0,
Valeriy Sizov's avatar
Valeriy Sizov committed
26 27
        "author":{
            "id":1,
28
            "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
29 30
            "email":"admin@local.host",
            "name":"Administrator",
31
            "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
32 33 34 35
            "created_at":"2012-04-29T08:46:00Z"
        },
        "assignee":{
            "id":1,
36
            "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
37 38
            "email":"admin@local.host",
            "name":"Administrator",
39
            "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
40 41 42 43 44 45
            "created_at":"2012-04-29T08:46:00Z"
        }
    }
]
```

46 47 48 49

## Get single MR

Shows information about a single merge request.
Valeriy Sizov's avatar
Valeriy Sizov committed
50 51

```
52
GET /projects/:id/merge_request/:merge_request_id
Valeriy Sizov's avatar
Valeriy Sizov committed
53 54 55 56
```

Parameters:

57
+ `id` (required) - The ID of a project
Valeriy Sizov's avatar
Valeriy Sizov committed
58 59 60 61 62
+ `merge_request_id` (required) - The ID of MR

```json
{
    "id":1,
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
63
    "iid":1,
Valeriy Sizov's avatar
Valeriy Sizov committed
64 65 66 67
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
68
    "state":"merged",
69 70
    "upvotes":0,
    "downvotes":0,
Valeriy Sizov's avatar
Valeriy Sizov committed
71 72
    "author":{
        "id":1,
73
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
74 75
        "email":"admin@local.host",
        "name":"Administrator",
76
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
77 78 79 80
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
81
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
82 83
        "email":"admin@local.host",
        "name":"Administrator",
84
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
85 86 87 88 89 90 91 92
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```


## Create MR

93
Creates a new merge request.
Valeriy Sizov's avatar
Valeriy Sizov committed
94 95

```
96
POST /projects/:id/merge_requests
Valeriy Sizov's avatar
Valeriy Sizov committed
97 98 99 100
```

Parameters:

101
+ `id` (required) - The ID of a project
Valeriy Sizov's avatar
Valeriy Sizov committed
102 103
+ `source_branch` (required) - The source branch
+ `target_branch` (required) - The target branch
104
+ `assignee_id` (optional)   - Assignee user ID
Valeriy Sizov's avatar
Valeriy Sizov committed
105 106 107 108 109 110 111 112 113
+ `title` (required)         - Title of MR

```json
{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
114
    "state":"opened",
115 116
    "upvotes":0,
    "downvotes":0,
Valeriy Sizov's avatar
Valeriy Sizov committed
117 118
    "author":{
        "id":1,
119
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
120 121
        "email":"admin@local.host",
        "name":"Administrator",
122
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
123 124 125 126
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
127
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
128 129
        "email":"admin@local.host",
        "name":"Administrator",
130
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
131 132 133 134 135
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```

136

Valeriy Sizov's avatar
Valeriy Sizov committed
137 138
## Update MR

139
Updates an existing merge request. You can change branches, title, or even close the MR.
Valeriy Sizov's avatar
Valeriy Sizov committed
140 141

```
142
PUT /projects/:id/merge_request/:merge_request_id
Valeriy Sizov's avatar
Valeriy Sizov committed
143 144 145 146
```

Parameters:

147
+ `id` (required)               - The ID of a project
Valeriy Sizov's avatar
Valeriy Sizov committed
148 149 150 151 152 153 154
+ `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

```json
155

Valeriy Sizov's avatar
Valeriy Sizov committed
156 157 158 159 160 161
{
    "id":1,
    "target_branch":"master",
    "source_branch":"test1",
    "project_id":3,
    "title":"test1",
162
    "state":"opened",
163 164
    "upvotes":0,
    "downvotes":0,
Valeriy Sizov's avatar
Valeriy Sizov committed
165 166
    "author":{
        "id":1,
167
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
168 169
        "email":"admin@local.host",
        "name":"Administrator",
170
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
171 172 173 174
        "created_at":"2012-04-29T08:46:00Z"
    },
    "assignee":{
        "id":1,
175
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
176 177
        "email":"admin@local.host",
        "name":"Administrator",
178
        "state":"active",
Valeriy Sizov's avatar
Valeriy Sizov committed
179 180 181 182
        "created_at":"2012-04-29T08:46:00Z"
    }
}
```
183 184


Valeriy Sizov's avatar
Valeriy Sizov committed
185 186
## Post comment to MR

187
Adds a comment to a merge request.
Valeriy Sizov's avatar
Valeriy Sizov committed
188 189

```
190
POST /projects/:id/merge_request/:merge_request_id/comments
Valeriy Sizov's avatar
Valeriy Sizov committed
191 192 193 194
```

Parameters:

195
+ `id` (required) - The ID of a project
196
+ `merge_request_id` (required) - ID of merge request
Valeriy Sizov's avatar
Valeriy Sizov committed
197 198 199 200 201 202 203
+ `note` (required) - Text of comment


```json
{
    "author":{
        "id":1,
204
        "username": "admin",
Valeriy Sizov's avatar
Valeriy Sizov committed
205 206 207 208 209 210 211 212
        "email":"admin@local.host",
        "name":"Administrator",
        "blocked":false,
        "created_at":"2012-04-29T08:46:00Z"
    },
    "note":"text1"
}
```