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>
This commit is contained in:
parent
0f6def90b7
commit
c8debd8fa4
@ -511,14 +511,18 @@ module GitHub
|
|||||||
if ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
if ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
||||||
ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
||||||
else
|
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.puts "protocol=https\nhost=github.com"
|
||||||
io.close_write
|
io.close_write
|
||||||
io.read
|
io.read
|
||||||
end
|
end
|
||||||
github_username = github_credentials[/username=(.+)/, 1]
|
github_username = github_credentials[/username=(.+)/, 1]
|
||||||
github_password = github_credentials[/password=(.+)/, 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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user