summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-21 17:43:58 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-21 17:43:58 +0100
commit17ed42e362032e3594ae1cf34e6a970be826bdca (patch)
treee87fec13bf16f3ed4c0638b933d21dfb067d523e /app/models
parent1be8a3e087efd8f7d7127a02fcabcfd7570b6e36 (diff)
parentc43fbaab937815e44856fe9d8371759986024e42 (diff)
downloadgitlab-ce-17ed42e362032e3594ae1cf34e6a970be826bdca.tar.gz
Merge branch 'issue_3452'
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 470b97a3c0f..7b89fe069ea 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -135,6 +135,16 @@ module Ci
predefined_variables + yaml_variables + project_variables + trigger_variables
end
+ def merge_request
+ merge_requests = MergeRequest.includes(:merge_request_diff)
+ .where(source_branch: ref, source_project_id: commit.gl_project_id)
+ .reorder(iid: :asc)
+
+ merge_requests.find do |merge_request|
+ merge_request.commits.any? { |ci| ci.id == commit.sha }
+ end
+ end
+
def project
commit.project
end