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 HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommitSignature

#commit, #verification_status

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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 Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.with_key_and_subkeys(gpg_key) ⇒ Object



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

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



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

def gpg_commit
  return unless commit

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

#gpg_keyObject



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

def gpg_key
  if gpg_key_id
    super
  elsif gpg_key_subkey_id
    gpg_key_subkey
  end
end

#gpg_key=(model) ⇒ Object



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

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



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

def gpg_key_primary_keyid
  super&.upcase
end

#signed_by_userObject



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

def signed_by_user
  gpg_key&.user
end

#typeObject



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

def type
  :gpg
end

#userObject



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

def user
  gpg_key&.user
end