diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-23 09:41:23 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-23 09:41:23 +0000 |
commit | f4101aeac73368adcab223f14bf3d4d92d718b8b (patch) | |
tree | ac74ffc67d9c8605cc5660157344c1cec345309b /app/services | |
parent | 9cffa428ad1b572437c38d7a3a41a26c35cc3576 (diff) | |
parent | 0d98f1bba2caf7ee5056510781c61db030551a66 (diff) | |
download | gitlab-ce-f4101aeac73368adcab223f14bf3d4d92d718b8b.tar.gz |
Merge branch 'rm-src-branch' into 'master'
Support remove source branch on merge w/ push options
See merge request gitlab-org/gitlab-ce!30728
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/push_options_handler_service.rb | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/app/services/merge_requests/push_options_handler_service.rb b/app/services/merge_requests/push_options_handler_service.rb index a24163331e8..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!( @@ -133,17 +127,8 @@ module MergeRequests ) 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 - ) + if push_options.key?(:remove_source_branch) + params[:force_remove_source_branch] = push_options[:remove_source_branch] end if push_options.key?(:target) @@ -153,6 +138,25 @@ module MergeRequests params end + def create_params(branch) + params = base_params + + params.merge!( + assignees: [current_user], + source_branch: branch, + source_project: project, + target_project: target_project + ) + + 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 |