Commit da969f7d authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'strong-memoize-build-merge-request' into 'master'

Use StrongMemoize for Ci::Build#merge_request

See merge request gitlab-org/gitlab!27577
parents 19769be8 050178e1
......@@ -598,19 +598,15 @@ module Ci
end
def merge_request
return @merge_request if defined?(@merge_request)
strong_memoize(:merge_request) do
merge_requests = MergeRequest.includes(:latest_merge_request_diff)
.where(source_branch: ref, source_project: pipeline.project)
.reorder(iid: :desc)
@merge_request ||=
begin
merge_requests = MergeRequest.includes(:latest_merge_request_diff)
.where(source_branch: ref,
source_project: pipeline.project)
.reorder(iid: :desc)
merge_requests.find do |merge_request|
merge_request.commit_shas.include?(pipeline.sha)
end
merge_requests.find do |merge_request|
merge_request.commit_shas.include?(pipeline.sha)
end
end
end
def repo_url
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment