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
commit25c4e336f48c4f9d549efc5511d87788a99d291c (patch)
treeecdd835337434a9c9bc83eca29c4869d6d5ddae6 /Library/Homebrew/utils.rb
parent3b818a19f9f3f94ae24b1907b49356155dbe7e96 (diff)
downloadbrew-25c4e336f48c4f9d549efc5511d87788a99d291c.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