aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorDaniel Lee Harple2013-05-18 08:27:22 -0400
committerJack Nagel2013-05-22 19:53:05 -0500
commitc2f9c5dff75c6568089f6610d40a67cc568a86af (patch)
treee09f74c3d05350bf1928beab3771f0fd61e097ac /Library/Homebrew
parenta113ebbfee5cfc96f95f1ac13b2ea110e58e05cc (diff)
downloadhomebrew-c2f9c5dff75c6568089f6610d40a67cc568a86af.tar.bz2
Added support for a GitHub Personal API Access token
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/global.rb1
-rw-r--r--Library/Homebrew/utils.rb4
2 files changed, 4 insertions, 1 deletions
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index 8d43afcf2..72f4f757d 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -77,6 +77,7 @@ else
MACOS = false
end
+HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{OS_VERSION})"
HOMEBREW_CURL_ARGS = '-f#LA'
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index ad943b6f8..ad86946aa 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -260,7 +260,9 @@ module GitHub extend self
def open url, headers={}, &block
require 'open-uri'
begin
- Kernel.open(url, {'User-Agent' => HOMEBREW_USER_AGENT}.merge(headers), &block)
+ default_headers = {'User-Agent' => HOMEBREW_USER_AGENT}
+ default_headers['Authorization'] = "token #{HOMEBREW_GITHUB_API_TOKEN}" if HOMEBREW_GITHUB_API_TOKEN
+ Kernel.open(url, default_headers.merge(headers), &block)
rescue OpenURI::HTTPError => e
if e.io.meta['x-ratelimit-remaining'].to_i <= 0
require 'vendor/multi_json'