diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-03-29 13:31:57 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-03-29 13:31:57 +0300 |
commit | a7cf61355a45a67ef404eeec3e38738f997ef2ec (patch) | |
tree | f64b6940e63c2f88a431f24a0cf890614578444e /app/models | |
parent | fea9400ec8a2a31d582a425226494f5fb9f90495 (diff) | |
parent | 7a2325e43c1fe726b4affc544449a763fb52b9e7 (diff) |
Merge branch 'sh-fix-gitaly-find-commit-caching' into 'master'
Allow ref name caching CommitService#find_commit
Closes #57083
See merge request gitlab-org/gitlab-ce!26248
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/pipeline.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 41f380cc1e4..e6370c37fde 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -465,9 +465,9 @@ module Ci end def latest? - return false unless ref && commit.present? + return false unless git_ref && commit.present? - project.commit(ref) == commit + project.commit(git_ref) == commit end def retried @@ -781,16 +781,18 @@ module Ci end def git_ref - if merge_request_event? - ## - # In the future, we're going to change this ref to - # merge request's merged reference, such as "refs/merge-requests/:iid/merge". - # In order to do that, we have to update GitLab-Runner's source pulling - # logic. - # See https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/1092 - Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s - else - super + strong_memoize(:git_ref) do + if merge_request_event? + ## + # In the future, we're going to change this ref to + # merge request's merged reference, such as "refs/merge-requests/:iid/merge". + # In order to do that, we have to update GitLab-Runner's source pulling + # logic. + # See https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/1092 + Gitlab::Git::BRANCH_REF_PREFIX + ref.to_s + else + super + end end end |