@@ -21,6 +21,8 @@ public class MergeRequestParams implements Serializable {
2121 private List <Long > reviewerIds ;
2222 private Long milestoneId ;
2323 private List <String > labels ;
24+ private List <String > addLabels ;
25+ private List <String > removeLabels ;
2426 private String description ;
2527 private Long targetProjectId ;
2628 private StateEvent stateEvent ;
@@ -132,6 +134,56 @@ public MergeRequestParams withLabels(String[] labels) {
132134 return (this );
133135 }
134136
137+ /**
138+ * Add labels to the merge request (without affecting existing labels).
139+ * If a label does not already exist, this creates a new project label and assigns it to the merge request.
140+ * This is for merge request updates only.
141+ *
142+ * @param addLabels the List of labels to add
143+ * @return the reference to this MergeRequestParams instance
144+ */
145+ public MergeRequestParams withAddLabels (List <String > addLabels ) {
146+ this .addLabels = addLabels ;
147+ return (this );
148+ }
149+
150+ /**
151+ * Add labels to the merge request (without affecting existing labels).
152+ * If a label does not already exist, this creates a new project label and assigns it to the merge request.
153+ * This is for merge request updates only.
154+ *
155+ * @param addLabels the array of labels to add
156+ * @return the reference to this MergeRequestParams instance
157+ */
158+ public MergeRequestParams withAddLabels (String [] addLabels ) {
159+ this .addLabels = (addLabels != null ? Arrays .asList (addLabels ) : null );
160+ return (this );
161+ }
162+
163+ /**
164+ * Remove labels from the merge request (without affecting other labels).
165+ * This is for merge request updates only.
166+ *
167+ * @param removeLabels the List of labels to remove
168+ * @return the reference to this MergeRequestParams instance
169+ */
170+ public MergeRequestParams withRemoveLabels (List <String > removeLabels ) {
171+ this .removeLabels = removeLabels ;
172+ return (this );
173+ }
174+
175+ /**
176+ * Remove labels from the merge request (without affecting other labels).
177+ * This is for merge request updates only.
178+ *
179+ * @param removeLabels the array of labels to remove
180+ * @return the reference to this MergeRequestParams instance
181+ */
182+ public MergeRequestParams withRemoveLabels (String [] removeLabels ) {
183+ this .removeLabels = (removeLabels != null ? Arrays .asList (removeLabels ) : null );
184+ return (this );
185+ }
186+
135187 /**
136188 * Set the description of the merge request. Limited to 1,048,576 characters.
137189 *
@@ -266,7 +318,10 @@ public GitLabForm getForm(boolean isCreate) {
266318 .withParam ("target_project_id" , targetProjectId )
267319 .withParam ("approvals_before_merge" , approvalsBeforeMerge );
268320 } else {
269- form .withParam ("state_event" , stateEvent ).withParam ("discussion_locked" , discussionLocked );
321+ form .withParam ("state_event" , stateEvent )
322+ .withParam ("discussion_locked" , discussionLocked )
323+ .withParam ("add_labels" , (addLabels != null ? String .join ("," , addLabels ) : null ))
324+ .withParam ("remove_labels" , (removeLabels != null ? String .join ("," , removeLabels ) : null ));
270325 }
271326
272327 return (form );
0 commit comments