Skip to content

Support add_labels / remove_labels in update Merge Request#1323

Open
mhagnumdw wants to merge 1 commit into
gitlab4j:mainfrom
mhagnumdw:add-remove-mr-labels
Open

Support add_labels / remove_labels in update Merge Request#1323
mhagnumdw wants to merge 1 commit into
gitlab4j:mainfrom
mhagnumdw:add-remove-mr-labels

Conversation

@mhagnumdw
Copy link
Copy Markdown
Contributor

Summary

Adds withAddLabels(...) and withRemoveLabels(...) to MergeRequestParams, mapping to the add_labels and remove_labels form parameters of the GitLab Update Merge Request endpoint: https://docs.gitlab.com/api/merge_requests/#update-a-merge-request

Motivation

Currently MergeRequestParams only exposes withLabels(...), which sends the full labels list and replaces the merge request's labels entirely. Adding or removing a single label therefore requires fetching the current label set and re-sending it.

The GitLab API already supports incremental label changes via add_labels and remove_labels only on the update endpoint: https://docs.gitlab.com/api/merge_requests/#update-a-merge-request

Changes

  • MergeRequestParams: two new fields (addLabels, removeLabels) and serialization wired into the update-only branch of getForm(boolean isCreate)
  • TestMergeRequestParams: add some tests

The change is strictly additive - existing behavior of withLabels(...) is unchanged.

Usage

mergeRequestApi.updateMergeRequest(projectIdOrPath, mrIid,
    new MergeRequestParams()
        .withAddLabels(List.of("bug"))
        .withRemoveLabels(List.of("wontfix")));

ps: I'm already using these changes in my application and everything is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant