Commit 940c05086ee595fd5ea7f77a07b78bff14efb7e2
1 parent
e7c930a5
Exists in
master
and in
4 other branches
Check for existing MR only for opened/reopened MR
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
app/models/merge_request.rb
@@ -92,11 +92,13 @@ class MergeRequest < ActiveRecord::Base | @@ -92,11 +92,13 @@ class MergeRequest < ActiveRecord::Base | ||
92 | errors.add :branch_conflict, "You can not use same branch for source and target branches" | 92 | errors.add :branch_conflict, "You can not use same branch for source and target branches" |
93 | end | 93 | end |
94 | 94 | ||
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 | 95 | + if opened? || reopened? |
96 | + similar_mrs = self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened | ||
97 | + similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id | ||
97 | 98 | ||
98 | - if similar_mrs.any? | ||
99 | - errors.add :base, "There is already an open merge request for this branches" | 99 | + if similar_mrs.any? |
100 | + errors.add :base, "There is already an open merge request for this branches" | ||
101 | + end | ||
100 | end | 102 | end |
101 | end | 103 | end |
102 | 104 |