aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorDavid MacMahon2013-10-22 16:18:31 -0700
committerMike McQuaid2013-10-25 21:12:28 +0100
commitf821514e9304828edd042e0710065aa0d554ba46 (patch)
treeaec4363cea1ed8716d75baa6121f7d53a8ab2cf2 /Library
parentcce81d6f3577bb66f3e4b8dfe74d546a38286cfb (diff)
downloadhomebrew-f821514e9304828edd042e0710065aa0d554ba46.tar.bz2
Add HOMEBREW_NO_GITHUB_API env var.
This patch allows users to "opt out" of using the GitHub API altogether by setting the HOMEBREW_NO_GITHUB_API environment variable. The value of the environment variable does not matter (it can even be empty!). For Bash/ZSH: export HOMEBREW_NO_GITHUB_API=1 Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/manpages/brew.1.md4
-rw-r--r--Library/Homebrew/cmd/search.rb2
-rw-r--r--Library/Homebrew/utils.rb6
3 files changed, 11 insertions, 1 deletions
diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md
index 5524c070b..595c062a2 100644
--- a/Library/Contributions/manpages/brew.1.md
+++ b/Library/Contributions/manpages/brew.1.md
@@ -524,6 +524,10 @@ can take several different forms:
*Note:* Homebrew will only try to print emoji on Lion or newer.
+ * HOMEBREW\_NO\_GITHUB\_API:
+ If set, Homebrew will not use the GitHub API for e.g searches or
+ fetching relevant issues on a failed install.
+
* HOMEBREW\_SOURCEFORGE\_MIRROR:
If set, Homebrew will use the value of `HOMEBREW_SOURCEFORGE_MIRROR` to
select a SourceForge mirror for downloading bottles.
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index b2febbdba..7319b1d90 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -61,7 +61,7 @@ module Homebrew extend self
count = local_results.length + tap_results.length
if count == 0 and not blacklisted? query
- puts "No formula found for #{query.inspect}. Searching open pull requests..."
+ puts "No formula found for #{query.inspect}."
begin
GitHub.find_pull_requests(rx) { |pull| puts pull }
rescue GitHub::Error => e
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index f3ac5e447..97dd708af 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -254,6 +254,9 @@ module GitHub extend self
Error = Class.new(StandardError)
def open url, headers={}, &block
+ # This is a no-op if the user is opting out of using the GitHub API.
+ return if ENV['HOMEBREW_NO_GITHUB_API']
+
require 'net/https' # for exception classes below
default_headers = {'User-Agent' => HOMEBREW_USER_AGENT}
@@ -296,6 +299,9 @@ module GitHub extend self
end
def find_pull_requests rx
+ return if ENV['HOMEBREW_NO_GITHUB_API']
+ puts "Searching open pull requests..."
+
query = rx.source.delete('.*').gsub('\\', '')
each_issue_matching(query) do |issue|