Class: CommitPresenter

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

Instance Attribute Summary

Attributes included from Gitlab::View::Presenter::Base

#subject

Instance Method Summary collapse

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

#initialize

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

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

Methods included from Gitlab::Allowable

#can?

Methods included from Gitlab::Routing

add_helpers, 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)

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

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

  commit.pipelines.any?
end

#signature_htmlObject


20
21
22
23
24
25
26
27
28
29
# File 'app/presenters/commit_presenter.rb', line 20

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) ⇒ Object


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

def status_for(ref)
  return unless can?(current_user, :read_commit_status, commit.project)

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