diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-13 18:04:55 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 14:58:26 -0200 |
commit | 033ea9d1e80544df5236ca045c88f649e41afbc7 (patch) | |
tree | c3a8d9db25c62183a44df0d670b2ab0e72678a74 /lib | |
parent | 0dbb47f00ee7333bbe76ddda853511c9120e2ad6 (diff) | |
download | gitlab-ce-033ea9d1e80544df5236ca045c88f649e41afbc7.tar.gz |
Move label management to services on merge requests API
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 67fdd0be927..bf8504e1101 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -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 |