Class: X509CommitSignature

Inherits:
ApplicationRecord show all
Includes:
ShaAttribute
Defined in:
app/models/x509_commit_signature.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.safe_create!(attributes) ⇒ Object


22
23
24
25
# File 'app/models/x509_commit_signature.rb', line 22

def self.safe_create!(attributes)
  create_with(attributes)
    .safe_find_or_create_by!(commit_sha: attributes[:commit_sha])
end

.unsigned_commit_shas(commit_shas) ⇒ Object

Find commits that are lacking a signature in the database at present


28
29
30
31
32
33
# File 'app/models/x509_commit_signature.rb', line 28

def self.unsigned_commit_shas(commit_shas)
  return [] if commit_shas.empty?

  signed = by_commit_sha(commit_shas).pluck(:commit_sha)
  commit_shas - signed
end

Instance Method Details

#commitObject


35
36
37
# File 'app/models/x509_commit_signature.rb', line 35

def commit
  project.commit(commit_sha)
end

#userObject


45
46
47
# File 'app/models/x509_commit_signature.rb', line 45

def user
  commit.committer
end

#x509_commitObject


39
40
41
42
43
# File 'app/models/x509_commit_signature.rb', line 39

def x509_commit
  return unless commit

  Gitlab::X509::Commit.new(commit)
end