Skip to content

fix: label unmarshaling for BasicMergeRequest list operations

Previously, functions returning []*BasicMergeRequest (ListMergeRequests, ListProjectMergeRequests, ListGroupMergeRequests) did not benefit from the custom unmarshaling logic that handles both plain labels (string slice) and detailed labels (list of objects). This was because MergeRequest.UnmarshalJSON is not invoked when unmarshalling a BasicMergeRequest directly.

This change fixes the issue by:

  • Unmarshaling API responses into []*MergeRequest (which has the proper label handling logic)
  • Extracting and returning the embedded BasicMergeRequest from each MergeRequest via the new toBasic() helper function

This ensures consistent label handling across all merge request list operations.

Added test coverage for ListGroupMergeRequests with the WithLabelDetails option to verify correct behavior.

While debugging I found that TestGetMergeRequest had expected/actual values switched around and fixed it.

Resolves: #2151 (closed)

Edited by Florian Forster

Merge request reports

Loading