From c8debd8fa46f8d7bf8ac329b4a53301b5271b895 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 10 Mar 2016 10:24:08 +0000 Subject: [PATCH] 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 --- Library/Homebrew/utils.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 18a3a18fb7..474c996124 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