diff options
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r-- | app/models/ci/build.rb | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 517f2312a76..b555b78cda6 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -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 |