diff options
| author | Mike McQuaid | 2016-03-08 11:43:39 +0000 |
|---|---|---|
| committer | Xu Cheng | 2016-03-08 20:52:11 +0800 |
| commit | 041c8502c5ec6f877211202313a5233132834d0b (patch) | |
| tree | 8c7cdc999454094a08a35ac3432b92a9ce92e469 /Library/Homebrew/cmd/gist-logs.rb | |
| parent | 0cbc2857019c31c01e4ab6901b59327884cc029d (diff) | |
| download | brew-041c8502c5ec6f877211202313a5233132834d0b.tar.bz2 | |
Set HOMEBREW_API_TOKEN from Git when available.
As requested in Homebrew/homebrew#46578. Falls back to existing functionality.
Closes Homebrew/homebrew#46578.
Closes Homebrew/homebrew#49846.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/cmd/gist-logs.rb')
| -rw-r--r-- | Library/Homebrew/cmd/gist-logs.rb | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index 29deb6551..acc9a10ea 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -37,7 +37,7 @@ module Homebrew if ARGV.include?("--new-issue") || ARGV.switch?("n") auth = :AUTH_TOKEN - unless HOMEBREW_GITHUB_API_TOKEN + unless GitHub.api_credentials puts "You can create a personal access token: https://github.com/settings/tokens" puts "and then set HOMEBREW_GITHUB_API_TOKEN as authentication method." puts @@ -115,15 +115,8 @@ module Homebrew end def make_request(path, data, auth) - headers = { - "User-Agent" => HOMEBREW_USER_AGENT, - "Accept" => "application/vnd.github.v3+json", - "Content-Type" => "application/json" - } - - if auth == :AUTH_TOKEN || (auth.nil? && HOMEBREW_GITHUB_API_TOKEN) - headers["Authorization"] = "token #{HOMEBREW_GITHUB_API_TOKEN}" - end + headers = GitHub.api_headers + headers["Content-Type"] = "application/json" request = Net::HTTP::Post.new(path, headers) |
