Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Reigel <mail@koffeinfrei.org>2017-02-24 22:07:57 +0300
committerAlexis Reigel <mail@koffeinfrei.org>2017-07-27 16:40:41 +0300
commit0e3d3d60bae48f3698f9e7b0e060edb67170b11e (patch)
tree56bbe22a0f589574aa8b7d21271ba3a610b1c418 /lib/gitlab/gpg.rb
parent41c96c45f2696af54dde81271741a6342db5d55a (diff)
email handling for gpg keys
Diffstat (limited to 'lib/gitlab/gpg.rb')
-rw-r--r--lib/gitlab/gpg.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb
index 64f18d00e46..73a4b691cff 100644
--- a/lib/gitlab/gpg.rb
+++ b/lib/gitlab/gpg.rb
@@ -2,6 +2,14 @@ module Gitlab
module Gpg
extend self
+ module CurrentKeyChain
+ extend self
+
+ def emails(fingerprint)
+ GPGME::Key.find(:public, fingerprint).flat_map { |raw_key| raw_key.uids.map(&:email) }
+ end
+ end
+
def fingerprints_from_key(key)
using_tmp_keychain do
import = GPGME::Key.import(key)
@@ -12,6 +20,18 @@ module Gitlab
end
end
+ def emails_from_key(key)
+ using_tmp_keychain do
+ import = GPGME::Key.import(key)
+
+ return [] if import.imported == 0
+
+ fingerprints = import.imports.map(&:fingerprint)
+
+ GPGME::Key.find(:public, fingerprints).flat_map { |raw_key| raw_key.uids.map(&:email) }
+ end
+ end
+
def add_to_keychain(key)
GPGME::Key.import(key)
end