Commit fb8a3e31 authored by Andrew Kumanyaev's avatar 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 ...@@ -122,12 +122,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def validates_merge_request def validates_merge_request
# Show git not found page if target branch doesn't exist # Show git not found page
return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch) # if there is no saved commits between source & target branch
if @merge_request.commits.blank?
# Show git not found page if source branch doesn't exist # and
# and there is no saved commits between source & target branch # if source target doesn't exist
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank? return invalid_mr if !@project.repository.branch_names.include?(@merge_request.target_branch)
# or if source branch doesn't exist
return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch)
end
end end
def define_show_vars 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