aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorXu Cheng2015-11-07 16:25:34 +0800
committerXu Cheng2015-11-09 15:34:20 +0800
commite97610b9160a3c94e4caf94ff6f036a8c9b4a78a (patch)
tree1225bf492494472e36d9f9fccc6680bfed5987f4 /Library/Homebrew/cmd
parent889bb5fb037273135dbc1b2c14c08ecc0162b64f (diff)
downloadbrew-e97610b9160a3c94e4caf94ff6f036a8c9b4a78a.tar.bz2
add Tap#install and Tap#uninstall
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/tap.rb47
-rw-r--r--Library/Homebrew/cmd/untap.rb13
2 files changed, 11 insertions, 49 deletions
diff --git a/Library/Homebrew/cmd/tap.rb b/Library/Homebrew/cmd/tap.rb
index d2c234bac..e07aa29eb 100644
--- a/Library/Homebrew/cmd/tap.rb
+++ b/Library/Homebrew/cmd/tap.rb
@@ -1,5 +1,4 @@
require "tap"
-require "descriptions"
module Homebrew
def tap
@@ -14,48 +13,22 @@ module Homebrew
puts Tap.select(&:pinned?).map(&:name)
else
user, repo = tap_args
- clone_target = ARGV.named[1]
- opoo "#{user}/#{repo} already tapped!" unless install_tap(user, repo, clone_target)
+ tap = Tap.fetch(user, repo)
+ tap.install(:clone_target => ARGV.named[1], :full_clone => ARGV.include?("--full"))
end
end
+ # @deprecated this method will be removed in the future, if no external commands use it.
def install_tap(user, repo, clone_target = nil)
- # ensure git is installed
- Utils.ensure_git_installed!
-
- tap = Tap.fetch user, repo
- return false if tap.installed?
- ohai "Tapping #{tap}"
- remote = clone_target || "https://github.com/#{tap.user}/homebrew-#{tap.repo}"
- args = %W[clone #{remote} #{tap.path}]
- args << "--depth=1" unless ARGV.include?("--full")
-
+ opoo "Homebrew.install_tap is deprecated, use Tap#install."
+ tap = Tap.fetch(user, repo)
begin
- safe_system "git", *args
- rescue Interrupt, ErrorDuringExecution
- ignore_interrupts do
- sleep 0.1 # wait for git to cleanup the top directory when interrupt happens.
- tap.path.parent.rmdir_if_possible
- end
- raise
- end
-
- formula_count = tap.formula_files.size
- puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{tap.path.abv})"
- Descriptions.cache_formulae(tap.formula_names)
-
- if !clone_target && tap.private?
- 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 #{tap.path}
- git remote set-url origin git@github.com:#{tap.user}/homebrew-#{tap.repo}.git
- EOS
+ tap.install(:clone_target => clone_target, :full_clone => ARGV.include?("--full"))
+ rescue TapAlreadyTappedError
+ false
+ else
+ true
end
-
- true
end
# Migrate tapped formulae from symlink-based to directory-based structure.
diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb
index c70a0d007..2d08ae8c7 100644
--- a/Library/Homebrew/cmd/untap.rb
+++ b/Library/Homebrew/cmd/untap.rb
@@ -1,5 +1,4 @@
require "cmd/tap" # for tap_args
-require "descriptions"
module Homebrew
def untap
@@ -7,17 +6,7 @@ module Homebrew
ARGV.named.each do |tapname|
tap = Tap.fetch(*tap_args(tapname))
-
- raise TapUnavailableError, tap.name unless tap.installed?
- puts "Untapping #{tap}... (#{tap.path.abv})"
-
- tap.unpin if tap.pinned?
-
- formula_count = tap.formula_files.size
- Descriptions.uncache_formulae(tap.formula_names)
- tap.path.rmtree
- tap.path.dirname.rmdir_if_possible
- puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}"
+ tap.uninstall
end
end
end