Class: CommitSignatures::GpgSignature

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

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CommitSignature

#commit, #user

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


13
14
15
16
17
18
19
20
21
# File 'app/models/commit_signatures/gpg_signature.rb', line 13

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


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

def gpg_commit
  return unless commit

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

#gpg_keyObject


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

def gpg_key
  if gpg_key_id
    super
  elsif gpg_key_subkey_id
    gpg_key_subkey
  end
end

#gpg_key=(model) ⇒ Object


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

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


43
44
45
# File 'app/models/commit_signatures/gpg_signature.rb', line 43

def gpg_key_primary_keyid
  super&.upcase
end