From 25c4e336f48c4f9d549efc5511d87788a99d291c Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 8 Feb 2014 20:41:11 -0500 Subject: Use GitHub wrapper for private tap check --- Library/Homebrew/cmd/tap.rb | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'Library/Homebrew/cmd') diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb index 58132faca..cc8f63d0f 100644 --- a/Library/Homebrew/cmd/tap.rb +++ b/Library/Homebrew/cmd/tap.rb @@ -31,20 +31,14 @@ module Homebrew extend self link_tap_formula(files) puts "Tapped #{files.length} formula" - # Figure out if this repo is private - # curl will throw an exception if the repo is private (Github returns a 404) - begin - curl('-Ifso', '/dev/null', "https://api.github.com/repos/#{repouser}/homebrew-#{repo}") - rescue - puts - puts "It looks like you tapped a private repository" - puts "In order to not input your credentials every time" - puts "you can use git HTTP credential caching or issue the" - puts "following command:" - puts - puts " cd #{tapd}" - puts " git remote set-url origin git@github.com:#{repouser}/homebrew-#{repo}.git" - puts + if private_tap?(repouser, repo) then puts <<-EOS.undent + It looks like you tapped a private repository. To avoid entering your + credentials each time you update, you can use git HTTP credential caching + or issue the following command: + + cd #{tapd} + git remote set-url origin git@github.com:#{repouser}/homebrew-#{repo}.git + EOS end true @@ -114,6 +108,13 @@ module Homebrew extend self [$1, $3] end + def private_tap?(user, repo) + GitHub.private_repo?(user, "homebrew-#{repo}") + rescue GitHub::HTTPNotFoundError => e + true + rescue GitHub::Error + false + end end -- cgit v1.2.3