mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-25 20:46:12 +10:00
IMprove MR validation logic
This commit is contained in:
@@ -92,7 +92,10 @@ class MergeRequest < ActiveRecord::Base
|
||||
errors.add :branch_conflict, "You can not use same branch for source and target branches"
|
||||
end
|
||||
|
||||
if self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened.any?
|
||||
similar_mrs = self.project.merge_requests.where(source_branch: source_branch, target_branch: target_branch).opened
|
||||
similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id
|
||||
|
||||
if similar_mrs.any?
|
||||
errors.add :base, "There is already an open merge request for this branches"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user