Move label management to services on merge requests API
This commit is contained in:
parent
0dbb47f00e
commit
033ea9d1e8
1 changed files with 4 additions and 11 deletions
|
@ -86,14 +86,11 @@ module API
|
|||
render_api_error!({ labels: errors }, 400)
|
||||
end
|
||||
|
||||
attrs[:labels] = params[:labels] if params[:labels]
|
||||
|
||||
merge_request = ::MergeRequests::CreateService.new(user_project, current_user, attrs).execute
|
||||
|
||||
if merge_request.valid?
|
||||
# Find or create labels and attach to issue
|
||||
if params[:labels].present?
|
||||
merge_request.add_labels_by_names(params[:labels].split(","), current_user)
|
||||
end
|
||||
|
||||
present merge_request, with: Entities::MergeRequest, current_user: current_user
|
||||
else
|
||||
handle_merge_request_errors! merge_request.errors
|
||||
|
@ -195,15 +192,11 @@ module API
|
|||
render_api_error!({ labels: errors }, 400)
|
||||
end
|
||||
|
||||
attrs[:labels] = params[:labels] if params[:labels]
|
||||
|
||||
merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, attrs).execute(merge_request)
|
||||
|
||||
if merge_request.valid?
|
||||
# Find or create labels and attach to issue
|
||||
unless params[:labels].nil?
|
||||
merge_request.remove_labels
|
||||
merge_request.add_labels_by_names(params[:labels].split(","), current_user)
|
||||
end
|
||||
|
||||
present merge_request, with: Entities::MergeRequest, current_user: current_user
|
||||
else
|
||||
handle_merge_request_errors! merge_request.errors
|
||||
|
|
Loading…
Reference in a new issue