2015-06-08 18:05:58 +08:00
|
|
|
require "tap"
|
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2012-03-02 20:28:54 +00:00
|
|
|
def tap
|
|
|
|
if ARGV.empty?
|
2015-06-08 18:05:58 +08:00
|
|
|
puts Tap.names
|
2012-08-04 15:06:37 -04:00
|
|
|
elsif ARGV.first == "--repair"
|
2015-05-08 20:19:12 +08:00
|
|
|
migrate_taps :force => true
|
2015-08-03 20:39:00 +02:00
|
|
|
elsif ARGV.first == "--list-official"
|
|
|
|
require "official_taps"
|
2015-08-21 12:33:33 +08:00
|
|
|
puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
|
|
|
|
elsif ARGV.first == "--list-pinned"
|
|
|
|
puts Tap.select(&:pinned?).map(&:name)
|
2012-03-02 20:28:54 +00:00
|
|
|
else
|
2015-06-02 17:27:05 -04:00
|
|
|
user, repo = tap_args
|
2015-11-07 16:25:34 +08:00
|
|
|
tap = Tap.fetch(user, repo)
|
2015-11-10 09:12:25 +00:00
|
|
|
unless tap.installed?
|
|
|
|
tap.install(:clone_target => ARGV.named[1],
|
|
|
|
:full_clone => ARGV.include?("--full"))
|
|
|
|
end
|
2012-03-02 20:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-07 16:25:34 +08:00
|
|
|
# @deprecated this method will be removed in the future, if no external commands use it.
|
2015-08-03 13:09:07 +01:00
|
|
|
def install_tap(user, repo, clone_target = nil)
|
2015-11-07 16:25:34 +08:00
|
|
|
opoo "Homebrew.install_tap is deprecated, use Tap#install."
|
|
|
|
tap = Tap.fetch(user, repo)
|
2015-08-28 14:33:00 +08:00
|
|
|
begin
|
2015-11-07 16:25:34 +08:00
|
|
|
tap.install(:clone_target => clone_target, :full_clone => ARGV.include?("--full"))
|
|
|
|
rescue TapAlreadyTappedError
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
2012-05-14 16:18:24 -06:00
|
|
|
end
|
2012-03-07 22:48:44 +00:00
|
|
|
end
|
|
|
|
|
2015-05-08 20:19:12 +08:00
|
|
|
# Migrate tapped formulae from symlink-based to directory-based structure.
|
2015-08-03 13:09:07 +01:00
|
|
|
def migrate_taps(options = {})
|
2015-05-08 20:19:12 +08:00
|
|
|
ignore = HOMEBREW_LIBRARY/"Formula/.gitignore"
|
|
|
|
return unless ignore.exist? || options.fetch(:force, false)
|
2015-08-17 17:08:23 +02:00
|
|
|
(HOMEBREW_LIBRARY/"Formula").children.each { |c| c.unlink if c.symlink? }
|
2015-05-08 20:19:12 +08:00
|
|
|
ignore.unlink if ignore.exist?
|
2012-08-04 15:06:37 -04:00
|
|
|
end
|
|
|
|
|
2012-03-02 20:28:54 +00:00
|
|
|
private
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def tap_args(tap_name = ARGV.named.first)
|
2015-02-01 12:11:54 -05:00
|
|
|
tap_name =~ HOMEBREW_TAP_ARGS_REGEX
|
2014-01-12 00:20:33 +09:00
|
|
|
raise "Invalid tap name" unless $1 && $3
|
2012-03-02 20:28:54 +00:00
|
|
|
[$1, $3]
|
|
|
|
end
|
2012-03-16 12:49:09 +00:00
|
|
|
end
|