Class: CommitSignatures::GpgSignature

Inherits:
ApplicationRecord show all
Includes:
CommitSignature, EachBatch, SignatureType
Defined in:
app/models/commit_signatures/gpg_signature.rb

Constant Summary

Constants included from SignatureType

SignatureType::TYPES

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommitSignature

#commit

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.with_key_and_subkeys(gpg_key) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/models/commit_signatures/gpg_signature.rb', line 23

def self.with_key_and_subkeys(gpg_key)
  subkey_ids = gpg_key.subkeys.pluck(:id)

  where(
    arel_table[:gpg_key_id].eq(gpg_key.id).or(
      arel_table[:gpg_key_subkey_id].in(subkey_ids)
    )
  )
end

Instance Method Details

#gpg_commitObject



57
58
59
60
61
# File 'app/models/commit_signatures/gpg_signature.rb', line 57

def gpg_commit
  return unless commit

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

#gpg_keyObject



45
46
47
48
49
50
51
# File 'app/models/commit_signatures/gpg_signature.rb', line 45

def gpg_key
  if gpg_key_id
    super
  elsif gpg_key_subkey_id
    gpg_key_subkey
  end
end

#gpg_key=(model) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/commit_signatures/gpg_signature.rb', line 33

def gpg_key=(model)
  case model
  when GpgKey
    super
  when GpgKeySubkey
    self.gpg_key_subkey = model
  when NilClass
    super
    self.gpg_key_subkey = nil
  end
end

#gpg_key_primary_keyidObject



53
54
55
# File 'app/models/commit_signatures/gpg_signature.rb', line 53

def gpg_key_primary_keyid
  super&.upcase
end

#signed_by_userObject



15
16
17
# File 'app/models/commit_signatures/gpg_signature.rb', line 15

def signed_by_user
  gpg_key&.user
end

#typeObject



19
20
21
# File 'app/models/commit_signatures/gpg_signature.rb', line 19

def type
  :gpg
end

#userObject



63
64
65
# File 'app/models/commit_signatures/gpg_signature.rb', line 63

def user
  gpg_key&.user
end