Skip to content
Snippets Groups Projects

GPG signed commits

Merged Alexis Reigel requested to merge siemens/gitlab-ce:feature/gpg-signed-commits into master
8 files
+ 75
8
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 14
1
@@ -20,7 +20,14 @@ class GpgKey < ActiveRecord::Base
# the error about the fingerprint
unless: -> { errors.has_key?(:key) }
before_validation :extract_fingerprint
validates :primary_keyid,
presence: true,
uniqueness: true,
# only validate when the `key` is valid, as we don't want the user to show
# the error about the fingerprint
unless: -> { errors.has_key?(:key) }
before_validation :extract_fingerprint, :extract_primary_keyid
after_create :notify_user
def key=(value)
@@ -49,6 +56,12 @@ def extract_fingerprint
self.fingerprint = Gitlab::Gpg.fingerprints_from_key(key).first
end
def extract_primary_keyid
# we can assume that the result only contains one item as the validation
# only allows one key
self.primary_keyid = Gitlab::Gpg.primary_keyids_from_key(key).first
end
def notify_user
run_after_commit { NotificationService.new.new_gpg_key(self) }
end
Loading