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-08-09 17:43:10 +0300
committerAlexis Reigel <mail@koffeinfrei.org>2017-08-11 09:38:42 +0300
commit6cd9888f6fc8bb1e0b6ff11ace8aacb19aedb268 (patch)
tree7aa89711bd0b4d2db833623fb7b051f996808653 /lib/gitlab/gpg.rb
parent3a9f210b5ce44f1a464e765ff6e95c1eac5363d8 (diff)
store gpg return directory locally
Diffstat (limited to 'lib/gitlab/gpg.rb')
-rw-r--r--lib/gitlab/gpg.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb
index e1d1724295a..653c56d925b 100644
--- a/lib/gitlab/gpg.rb
+++ b/lib/gitlab/gpg.rb
@@ -44,19 +44,23 @@ module Gitlab
def using_tmp_keychain
Dir.mktmpdir do |dir|
- @original_dirs ||= [GPGME::Engine.dirinfo('homedir')]
- @original_dirs.push(dir)
+ previous_dir = current_home_dir
GPGME::Engine.home_dir = dir
return_value = yield
- @original_dirs.pop
-
- GPGME::Engine.home_dir = @original_dirs[-1]
+ GPGME::Engine.home_dir = previous_dir
return_value
end
end
+
+ # 1. Returns the custom home directory if one has been set by calling
+ # `GPGME::Engine.home_dir=`
+ # 2. Returns the default home directory otherwise
+ def current_home_dir
+ GPGME::Engine.info.first.home_dir || GPGME::Engine.dirinfo('homedir')
+ end
end
end