1
1
package org .gitlab4j .api ;
2
2
3
- import java .util .List ;
4
- import java .util .Optional ;
5
-
6
- import javax .ws .rs .core .Form ;
7
- import javax .ws .rs .core .GenericType ;
8
- import javax .ws .rs .core .MultivaluedMap ;
9
- import javax .ws .rs .core .Response ;
10
-
11
3
import org .gitlab4j .api .GitLabApi .ApiVersion ;
12
4
import org .gitlab4j .api .models .Commit ;
13
5
import org .gitlab4j .api .models .MergeRequest ;
14
6
import org .gitlab4j .api .models .MergeRequestFilter ;
15
7
import org .gitlab4j .api .models .Participant ;
16
8
9
+ import javax .ws .rs .core .Form ;
10
+ import javax .ws .rs .core .GenericType ;
11
+ import javax .ws .rs .core .MultivaluedMap ;
12
+ import javax .ws .rs .core .Response ;
13
+ import java .util .List ;
14
+ import java .util .Optional ;
15
+
17
16
/**
18
17
* This class implements the client side API for the GitLab merge request calls.
19
18
*/
@@ -269,11 +268,13 @@ public Pager<Commit> getCommits(int projectId, int mergeRequestIid, int itemsPer
269
268
* @param labels labels for MR, optional
270
269
* @param milestoneId the ID of a milestone, optional
271
270
* @param removeSourceBranch Flag indicating if a merge request should remove the source branch when merging, optional
271
+ * @param squash Squash commits into a single commit when merging, optional
272
272
* @return the created MergeRequest instance
273
273
* @throws GitLabApiException if any exception occurs
274
+ * @since GitLab Starter 8.17, GitLab CE 11.0.
274
275
*/
275
276
public MergeRequest createMergeRequest (Integer projectId , String sourceBranch , String targetBranch , String title , String description , Integer assigneeId ,
276
- Integer targetProjectId , String [] labels , Integer milestoneId , Boolean removeSourceBranch )
277
+ Integer targetProjectId , String [] labels , Integer milestoneId , Boolean removeSourceBranch , Boolean squash )
277
278
throws GitLabApiException {
278
279
if (projectId == null ) {
279
280
throw new RuntimeException ("projectId cannot be null" );
@@ -289,11 +290,37 @@ public MergeRequest createMergeRequest(Integer projectId, String sourceBranch, S
289
290
addFormParam (formData , "labels" , labels == null ? null : String .join ("," , labels ), false );
290
291
addFormParam (formData , "milestone_id" , milestoneId , false );
291
292
addFormParam (formData , "remove_source_branch" , removeSourceBranch , false );
293
+ addFormParam (formData , "squash" , squash , false );
292
294
293
295
Response response = post (Response .Status .CREATED , formData , "projects" , projectId , "merge_requests" );
294
296
return (response .readEntity (MergeRequest .class ));
295
297
}
296
298
299
+
300
+ /**
301
+ * Creates a merge request and optionally assigns a reviewer to it.
302
+ *
303
+ * POST /projects/:id/merge_requests
304
+ *
305
+ * @param projectId the ID of a project, required
306
+ * @param sourceBranch the source branch, required
307
+ * @param targetBranch the target branch, required
308
+ * @param title the title for the merge request, required
309
+ * @param description the description of the merge request
310
+ * @param assigneeId the Assignee user ID, optional
311
+ * @param targetProjectId the ID of a target project, optional
312
+ * @param labels labels for MR, optional
313
+ * @param milestoneId the ID of a milestone, optional
314
+ * @param removeSourceBranch Flag indicating if a merge request should remove the source branch when merging, optional
315
+ * @return the created MergeRequest instance
316
+ * @throws GitLabApiException if any exception occurs
317
+ */
318
+ public MergeRequest createMergeRequest (Integer projectId , String sourceBranch , String targetBranch , String title , String description , Integer assigneeId ,
319
+ Integer targetProjectId , String [] labels , Integer milestoneId , Boolean removeSourceBranch )
320
+ throws GitLabApiException {
321
+ return createMergeRequest (projectId , sourceBranch , targetBranch , title , description , assigneeId , targetProjectId , labels , milestoneId , removeSourceBranch , null );
322
+ }
323
+
297
324
/**
298
325
* Creates a merge request and optionally assigns a reviewer to it.
299
326
*
@@ -511,7 +538,7 @@ public MergeRequest acceptMergeRequest(Integer projectId, Integer mergeRequestIi
511
538
* @return the merged merge request
512
539
* @throws GitLabApiException if any exception occurs
513
540
*/
514
- public MergeRequest acceptMergeRequest (Integer projectId , Integer mergeRequestIid ,
541
+ public MergeRequest acceptMergeRequest (Integer projectId , Integer mergeRequestIid ,
515
542
String mergeCommitMessage , Boolean shouldRemoveSourceBranch , Boolean mergeWhenPipelineSucceeds )
516
543
throws GitLabApiException {
517
544
return (acceptMergeRequest (projectId , mergeRequestIid , mergeCommitMessage ,
@@ -540,7 +567,7 @@ public MergeRequest acceptMergeRequest(Integer projectId, Integer mergeRequestIi
540
567
* @return the merged merge request
541
568
* @throws GitLabApiException if any exception occurs
542
569
*/
543
- public MergeRequest acceptMergeRequest (Integer projectId , Integer mergeRequestIid ,
570
+ public MergeRequest acceptMergeRequest (Integer projectId , Integer mergeRequestIid ,
544
571
String mergeCommitMessage , Boolean shouldRemoveSourceBranch , Boolean mergeWhenPipelineSucceeds , String sha )
545
572
throws GitLabApiException {
546
573
0 commit comments