Class: Gitlab::SignedCommit

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/signed_commit.rb

Direct Known Subclasses

Gpg::Commit, X509::Commit

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(commit) ⇒ SignedCommit

Returns a new instance of SignedCommit.


9
10
11
12
13
14
15
16
17
18
# File 'lib/gitlab/signed_commit.rb', line 9

def initialize(commit)
  @commit = commit

  if commit.project
    repo = commit.project.repository.raw_repository
    @signature_data = Gitlab::Git::Commit.extract_signature_lazily(repo, commit.sha || commit.id)
  end

  lazy_signature
end

Instance Method Details

#signatureObject


20
21
22
# File 'lib/gitlab/signed_commit.rb', line 20

def signature
  return unless @commit.has_signature?
end

#signature_textObject


24
25
26
27
28
# File 'lib/gitlab/signed_commit.rb', line 24

def signature_text
  strong_memoize(:signature_text) do
    @signature_data.itself ? @signature_data[0] : nil
  end
end

#signed_textObject


30
31
32
33
34
# File 'lib/gitlab/signed_commit.rb', line 30

def signed_text
  strong_memoize(:signed_text) do
    @signature_data.itself ? @signature_data[1] : nil
  end
end