Commit fb8a3e319a59cedd19191a169cfae08b2923ecbe
1 parent
b19bffc5
Exists in
master
and in
4 other branches
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 :(
Showing
1 changed file
with
10 additions
and
6 deletions
Show diff stats
app/controllers/projects/merge_requests_controller.rb
@@ -122,12 +122,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController | @@ -122,12 +122,16 @@ class Projects::MergeRequestsController < Projects::ApplicationController | ||
122 | end | 122 | end |
123 | 123 | ||
124 | def validates_merge_request | 124 | def validates_merge_request |
125 | - # Show git not found page if target branch doesn't exist | ||
126 | - return invalid_mr unless @project.repository.branch_names.include?(@merge_request.target_branch) | ||
127 | - | ||
128 | - # Show git not found page if source branch doesn't exist | ||
129 | - # and there is no saved commits between source & target branch | ||
130 | - return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) && @merge_request.commits.blank? | 125 | + # Show git not found page |
126 | + # if there is no saved commits between source & target branch | ||
127 | + if @merge_request.commits.blank? | ||
128 | + # and | ||
129 | + # if source target doesn't exist | ||
130 | + return invalid_mr if !@project.repository.branch_names.include?(@merge_request.target_branch) | ||
131 | + | ||
132 | + # or if source branch doesn't exist | ||
133 | + return invalid_mr if !@project.repository.branch_names.include?(@merge_request.source_branch) | ||
134 | + end | ||
131 | end | 135 | end |
132 | 136 | ||
133 | def define_show_vars | 137 | def define_show_vars |