Class: CommitPresenter

Inherits:
Gitlab::View::Presenter::Delegated show all
Includes:
GlobalID::Identification
Defined in:
app/presenters/commit_presenter.rb

Instance Method Summary collapse

Methods inherited from Gitlab::View::Presenter::Delegated

#initialize

Methods included from Gitlab::Utils::DelegatorOverride

#delegator_override, #delegator_override_with, #delegator_target, validator, validators, verify!

Methods included from Gitlab::View::Presenter::Base

#__subject__, #can?, #declarative_policy_delegate, #is_a?, #path_with_line_numbers, #present, #url_builder, #web_path, #web_url

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

includes_helpers, redirect_legacy_paths, url_helpers

Constructor Details

This class inherits a constructor from Gitlab::View::Presenter::Delegated

Instance Method Details

#any_pipelines?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'app/presenters/commit_presenter.rb', line 22

def any_pipelines?
  return false unless can?(current_user, :read_pipeline, commit.project)

  commit.pipelines.any?
end

#detailed_status_for(ref) ⇒ Object



8
9
10
11
12
13
# File 'app/presenters/commit_presenter.rb', line 8

def detailed_status_for(ref)
  return unless can?(current_user, :read_pipeline, commit.latest_pipeline(ref))
  return unless can?(current_user, :read_commit_status, commit.project)

  commit.latest_pipeline(ref)&.detailed_status(current_user)
end

#signature_htmlObject



32
33
34
35
36
37
38
39
40
41
# File 'app/presenters/commit_presenter.rb', line 32

def signature_html
  return unless commit.has_signature?

  ApplicationController.renderer.render(
    'projects/commit/_signature',
    locals: { signature: commit.signature },
    layout: false,
    formats: [:html]
  )
end

#status_for(ref = nil) ⇒ Object



15
16
17
18
19
20
# File 'app/presenters/commit_presenter.rb', line 15

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

#tags_for_displayObject



28
29
30
# File 'app/presenters/commit_presenter.rb', line 28

def tags_for_display
  commit.referenced_by&.map { |tag_name| Gitlab::Git.ref_name(tag_name) }
end