Refactored ‘from’ and ‘to’ variable preservation
This commit is contained in:
parent
87c39b6d39
commit
9844c1f222
1 changed files with 6 additions and 10 deletions
|
@ -27,8 +27,11 @@ class Projects::CompareController < Projects::ApplicationController
|
|||
def create
|
||||
if params[:from].blank? || params[:to].blank?
|
||||
flash[:alert] = "You must select from and to branches"
|
||||
from_to_preservation = from_to_hash(params)
|
||||
redirect_to namespace_project_compare_index_path(@project.namespace, @project, from_to_preservation)
|
||||
from_to_vars = {
|
||||
from: params[:from].presence,
|
||||
to: params[:to].presence
|
||||
}
|
||||
redirect_to namespace_project_compare_index_path(@project.namespace, @project, from_to_vars)
|
||||
else
|
||||
redirect_to namespace_project_compare_path(@project.namespace, @project,
|
||||
params[:from], params[:to])
|
||||
|
@ -62,11 +65,4 @@ class Projects::CompareController < Projects::ApplicationController
|
|||
@merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened.
|
||||
find_by(source_project: @project, source_branch: @head_ref, target_branch: @start_ref)
|
||||
end
|
||||
|
||||
def from_to_hash(params)
|
||||
return_hash = {}
|
||||
return_hash[:from] = params[:from].presence
|
||||
return_hash[:to] = params[:to].presence
|
||||
return_hash
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue