Commit a59fe739fe05bcdf0eed06f1aea276a1236c32d2
1 parent
977146f5
Exists in
master
and in
4 other branches
IMprove MR validation logic
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
app/models/merge_request.rb
... | ... | @@ -92,7 +92,10 @@ class MergeRequest < ActiveRecord::Base |
92 | 92 | errors.add :branch_conflict, "You can not use same branch for source and target branches" |
93 | 93 | end |
94 | 94 | |
95 | - if self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened.any? | |
95 | + similar_mrs = self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened | |
96 | + similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id | |
97 | + | |
98 | + if similar_mrs.any? | |
96 | 99 | errors.add :base, "There is already an open merge request for this branches" |
97 | 100 | end |
98 | 101 | end | ... | ... |