summaryrefslogtreecommitdiff
path: root/app/models/ci
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2017-12-05 14:15:30 +0100
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2017-12-19 10:05:40 +0100
commitc6edae38870a4228e3b964d647b9ef588df11f27 (patch)
tree9cb0b2dbdaa62cd889f3accc421d282b747e4bc9 /app/models/ci
parent3870a1bde276144a05a31185ede7a5032818d489 (diff)
downloadgitlab-ce-c6edae38870a4228e3b964d647b9ef588df11f27.tar.gz
Load commit in batches for pipelines#index
Uses `list_commits_by_oid` on the CommitService, to request the needed commits for pipelines. These commits are needed to display the user that created the commit and the commit title. This includes fixes for tests failing that depended on the commit being `nil`. However, now these are batch loaded, this doesn't happen anymore and the commits are an instance of BatchLoader.
Diffstat (limited to 'app/models/ci')
-rw-r--r--app/models/ci/pipeline.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 28f154581a9..d4690da3be6 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -287,8 +287,12 @@ module Ci
Ci::Pipeline.truncate_sha(sha)
end
+ # NOTE: This is loaded lazily and will never be nil, even if the commit
+ # cannot be found.
+ #
+ # Use constructs like: `pipeline.commit.present?`
def commit
- @commit ||= project.commit_by(oid: sha)
+ @commit ||= Commit.lazy(project, sha)
end
def branch?
@@ -338,12 +342,9 @@ module Ci
end
def latest?
- return false unless ref
-
- commit = project.commit(ref)
- return false unless commit
+ return false unless ref && commit.present?
- commit.sha == sha
+ project.commit(ref) == commit
end
def retried