2019-02-02 18:00:53 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
class CommitPresenter < Gitlab::View::Presenter::Delegated
|
|
|
|
include GlobalID::Identification
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
presents ::Commit, as: :commit
|
2019-02-02 18:00:53 +05:30
|
|
|
|
2022-09-01 20:07:04 +05:30
|
|
|
def detailed_status_for(ref)
|
|
|
|
return unless can?(current_user, :read_pipeline, commit.latest_pipeline(ref))
|
2019-12-21 20:55:43 +05:30
|
|
|
return unless can?(current_user, :read_commit_status, commit.project)
|
|
|
|
|
|
|
|
commit.latest_pipeline(ref)&.detailed_status(current_user)
|
2019-02-02 18:00:53 +05:30
|
|
|
end
|
|
|
|
|
2022-09-01 20:07:04 +05:30
|
|
|
def status_for(ref = nil)
|
|
|
|
return unless can?(current_user, :read_pipeline, commit.latest_pipeline(ref))
|
|
|
|
return unless can?(current_user, :read_commit_status, commit.project)
|
|
|
|
|
|
|
|
commit.status(ref)
|
|
|
|
end
|
|
|
|
|
2019-02-02 18:00:53 +05:30
|
|
|
def any_pipelines?
|
2019-12-21 20:55:43 +05:30
|
|
|
return false unless can?(current_user, :read_pipeline, commit.project)
|
|
|
|
|
|
|
|
commit.pipelines.any?
|
2019-02-02 18:00:53 +05:30
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
def tags_for_display
|
2023-07-09 08:55:56 +05:30
|
|
|
commit.referenced_by&.map { |tag_name| Gitlab::Git.ref_name(tag_name) }
|
2023-05-27 22:25:52 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def signature_html
|
|
|
|
return unless commit.has_signature?
|
|
|
|
|
|
|
|
ApplicationController.renderer.render(
|
|
|
|
'projects/commit/_signature',
|
|
|
|
locals: { signature: commit.signature },
|
|
|
|
layout: false,
|
|
|
|
formats: [:html]
|
|
|
|
)
|
|
|
|
end
|
2019-02-02 18:00:53 +05:30
|
|
|
end
|