BigW Consortium Gitlab

Commit fb8a3e31 by Andrew Kumanyaev

Update logic for validates_merge_request for tree of MR

For case: Merge request №1: branch "feature" to "release" and remove "feature" branch Merge request №2: branch "release" to "master" and remove "release" branch Merge request №1 - broken :(
parent b19bffc5
......@@ -122,12 +122,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def validates_merge_request
# Show git not found page if target branch doesn't exist
return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch)
# Show git not found page
# if there is no saved commits between source & target branch
if @merge_request.commits.blank?
# and
# if source target doesn't exist
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.target_branch)
# Show git not found page if source branch doesn't exist
# and there is no saved commits between source & target branch
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank?
# or if source branch doesn't exist
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch)
end
end
def define_show_vars
......
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