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:
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