aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2016-03-10 10:24:08 +0000
committerXu Cheng2016-03-10 18:45:43 +0800
commitc8debd8fa46f8d7bf8ac329b4a53301b5271b895 (patch)
tree1042a35998915c30e43d3a760d26399f81af0d71 /Library/Homebrew
parent0f6def90b7993fdb587b06207d88f3b818be9c6c (diff)
downloadbrew-c8debd8fa46f8d7bf8ac329b4a53301b5271b895.tar.bz2
utils: API Git credential tweaks.
- Use empty array when `git credential-osxkeychain` lookup fails to cache and avoid rerunning it when there's no valid results. - Redirect `stderr` to avoid printing errors when there's a failure or no `git credential-osxkeychain` installed. Closes Homebrew/homebrew#49954. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/utils.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 18a3a18fb..474c99612 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -511,14 +511,18 @@ module GitHub
if ENV["HOMEBREW_GITHUB_API_TOKEN"]
ENV["HOMEBREW_GITHUB_API_TOKEN"]
else
- github_credentials = IO.popen("git credential-osxkeychain get", "w+") do |io|
+ github_credentials = Utils.popen("git credential-osxkeychain get", "w+") do |io|
io.puts "protocol=https\nhost=github.com"
io.close_write
io.read
end
github_username = github_credentials[/username=(.+)/, 1]
github_password = github_credentials[/password=(.+)/, 1]
- [github_password, github_username] if github_username && github_password
+ if github_username && github_password
+ [github_password, github_username]
+ else
+ []
+ end
end
end
end