diff options
-rw-r--r-- | app/services/merge_requests/push_options_handler_service.rb | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/app/services/merge_requests/push_options_handler_service.rb b/app/services/merge_requests/push_options_handler_service.rb index 7ca8e1d76a3..6d70b5106c7 100644 --- a/app/services/merge_requests/push_options_handler_service.rb +++ b/app/services/merge_requests/push_options_handler_service.rb @@ -117,14 +117,8 @@ module MergeRequests collect_errors_from_merge_request(merge_request) unless merge_request.valid? end - def create_params(branch) - params = { - assignees: [current_user], - source_branch: branch, - source_project: project, - target_branch: push_options[:target] || target_project.default_branch, - target_project: target_project - } + def base_params + params = {} if push_options.key?(:merge_when_pipeline_succeeds) params.merge!( @@ -137,30 +131,32 @@ module MergeRequests params[:force_remove_source_branch] = push_options[:remove_source_branch] end + if push_options.key?(:target) + params[:target_branch] = push_options[:target] + end + params end - def update_params - params = {} - - if push_options.key?(:merge_when_pipeline_succeeds) - params.merge!( - merge_when_pipeline_succeeds: push_options[:merge_when_pipeline_succeeds], - merge_user: current_user - ) - end + def create_params(branch) + params = base_params - if push_options.key?(:remove_source_branch) - params[:force_remove_source_branch] = push_options[:remove_source_branch] - end + params.merge!( + assignees: [current_user], + source_branch: branch, + source_project: project, + target_project: target_project + ) - if push_options.key?(:target) - params[:target_branch] = push_options[:target] - end + params[:target_branch] ||= target_project.default_branch params end + def update_params + base_params + end + def collect_errors_from_merge_request(merge_request) merge_request.errors.full_messages.each do |error| errors << error |