Commit 4aa0c99f authored by Christian Couder's avatar Christian Couder Committed by Ash McKenzie

Refactor force_remove_source_branch handling

In build_service.rb, let's move most of the force_remove_source_branch
handling code into a new force_remove_source_branch() method.
parent cb8391c5
......@@ -16,13 +16,8 @@ module MergeRequests
merge_request.source_project = find_source_project
merge_request.target_project = find_target_project
# Source project sets the default source branch removal setting
merge_request.merge_params['force_remove_source_branch'] =
if params.key?(:force_remove_source_branch)
params.delete(:force_remove_source_branch)
else
merge_request.source_project.remove_source_branch_after_merge?
end
# Force remove the source branch?
merge_request.merge_params['force_remove_source_branch'] = force_remove_source_branch
self.params = assign_allowed_merge_params(merge_request, params)
......@@ -74,6 +69,14 @@ module MergeRequests
:errors,
to: :merge_request
def force_remove_source_branch
if params.key?(:force_remove_source_branch)
params.delete(:force_remove_source_branch)
else
merge_request.source_project.remove_source_branch_after_merge?
end
end
def find_source_project
source_project = project_from_params(:source_project)
return source_project if source_project.present? && can?(current_user, :create_merge_request_from, source_project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment