From 08388b149e5a45d21214170a038a118eeaba850d Mon Sep 17 00:00:00 2001 From: Daniel Lee Harple Date: Sat, 18 May 2013 08:27:22 -0400 Subject: Added support for a GitHub Personal API Access token Signed-off-by: Jack Nagel --- Library/Contributions/manpages/brew.1.md | 6 ++++++ Library/Homebrew/global.rb | 1 + Library/Homebrew/utils.rb | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 008465294..b0cca1867 100644 --- a/Library/Contributions/manpages/brew.1.md +++ b/Library/Contributions/manpages/brew.1.md @@ -459,6 +459,12 @@ can take several different forms: directories. TextMate can handle this correctly in project mode, but many editors will do strange things in this case. + * HOMEBREW\_GITHUB\_API\_TOKEN: + A personal GitHub API Access token, which you can be create at + . If set, GitHub will allow you a + greater number of API requests. See + for more information. + * HOMEBREW\_KEEP\_INFO: If set, Homebrew will not remove files from `share/info`, allowing them to be linked from the Cellar. To access these info files, prepend 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' -- cgit v1.2.3