diff options
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r-- | app/models/commit.rb | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index a442f607fbf..aae49c36899 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -119,10 +119,22 @@ class Commit @raw = raw_commit @project = project - @statuses = {} @gpg_commit = Gitlab::Gpg::Commit.new(self) if project end + delegate \ + :pipelines, + :last_pipeline, + :latest_pipeline, + :latest_pipeline_for_project, + :set_latest_pipeline_for_ref, + :status, + to: :with_pipeline + + def with_pipeline + @with_pipeline ||= CommitWithPipeline.new(self) + end + def id raw.id end @@ -245,10 +257,9 @@ class Commit end def author - # We use __sync so that we get the actual objects back (including an actual - # nil), instead of a wrapper, as returning a wrapped nil breaks a lot of - # code. - lazy_author.__sync + strong_memoize(:author) do + lazy_author&.itself + end end request_cache(:author) { author_email.downcase } @@ -301,30 +312,6 @@ class Commit ) end - def pipelines - project.ci_pipelines.where(sha: sha) - end - - def last_pipeline - strong_memoize(:last_pipeline) do - pipelines.last - end - end - - def status(ref = nil) - return @statuses[ref] if @statuses.key?(ref) - - @statuses[ref] = status_for_project(ref, project) - end - - def status_for_project(ref, pipeline_project) - pipeline_project.ci_pipelines.latest_status_per_commit(id, ref)[id] - end - - def set_status_for_ref(ref, status) - @statuses[ref] = status - end - def signature return @signature if defined?(@signature) @@ -427,7 +414,7 @@ class Commit if entry[:type] == :blob blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project) - blob.image? || blob.video? ? :raw : :blob + blob.image? || blob.video? || blob.audio? ? :raw : :blob else entry[:type] end |