aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorJack Nagel2014-02-08 20:41:11 -0500
committerJack Nagel2014-02-08 20:41:11 -0500
commit0e13b9ea365d15b75fa029d0b6510e6b5baa0390 (patch)
treecadc3d6d60cbce45bfcb60cc3e48009ae3008a40 /Library/Homebrew/utils.rb
parent849d6a0fb5fb21183c4f7fc8389bb1bc2aac06ba (diff)
downloadhomebrew-0e13b9ea365d15b75fa029d0b6510e6b5baa0390.tar.bz2
Use GitHub wrapper for private tap check
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 6ec85a714..ed1f691d0 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -253,6 +253,7 @@ module GitHub extend self
Error = Class.new(StandardError)
RateLimitExceededError = Class.new(Error)
+ HTTPNotFoundError = Class.new(Error)
def open url, headers={}, &block
# This is a no-op if the user is opting out of using the GitHub API.
@@ -276,6 +277,8 @@ module GitHub extend self
You may want to create an API token: https://github.com/settings/applications
and then set HOMEBREW_GITHUB_API_TOKEN.
EOS
+ elsif e.io.status.first == "404"
+ raise HTTPNotFoundError, e.message, e.backtrace
else
raise Error, e.message, e.backtrace
end
@@ -334,4 +337,9 @@ module GitHub extend self
prs.each {|i| yield "#{i["title"]} (#{i["pull_request"]["html_url"]})" }
end
+
+ def private_repo?(user, repo)
+ uri = URI.parse("https://api.github.com/repos/#{user}/#{repo}")
+ open(uri) { |json| json["private"] }
+ end
end