diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-13 15:22:15 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2017-07-27 15:44:39 +0200 |
commit | cd01e82873b3cd471203dbf557c71571fd683d16 (patch) | |
tree | 08372f91287ec4c9a14d95044a0eff7fbe8e78c3 /lib/gitlab/gpg | |
parent | 506836a695ae40ff200add21c639f3d13aaee9e9 (diff) | |
download | gitlab-ce-cd01e82873b3cd471203dbf557c71571fd683d16.tar.gz |
store gpg user name and email on the signature
Diffstat (limited to 'lib/gitlab/gpg')
-rw-r--r-- | lib/gitlab/gpg/commit.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/gitlab/gpg/commit.rb b/lib/gitlab/gpg/commit.rb index 50e8d71bb13..55428b85207 100644 --- a/lib/gitlab/gpg/commit.rb +++ b/lib/gitlab/gpg/commit.rb @@ -26,10 +26,7 @@ module Gitlab def update_signature!(cached_signature) using_keychain do |gpg_key| - cached_signature.update_attributes!( - valid_signature: gpg_signature_valid_signature_value(gpg_key), - gpg_key: gpg_key - ) + cached_signature.update_attributes!(attributes(gpg_key)) end end @@ -59,18 +56,30 @@ module Gitlab end def create_cached_signature!(gpg_key) - GpgSignature.create!( + GpgSignature.create!(attributes(gpg_key)) + end + + def attributes(gpg_key) + user_infos = user_infos(gpg_key) + + { commit_sha: commit.sha, project: commit.project, gpg_key: gpg_key, gpg_key_primary_keyid: gpg_key&.primary_keyid || verified_signature.fingerprint, + gpg_key_user_name: user_infos[:name], + gpg_key_user_email: user_infos[:email], valid_signature: gpg_signature_valid_signature_value(gpg_key) - ) + } end def gpg_signature_valid_signature_value(gpg_key) !!(gpg_key && gpg_key.verified? && verified_signature.valid?) end + + def user_infos(gpg_key) + gpg_key&.verified_user_infos&.first || gpg_key&.user_infos&.first || {} + end end end end |