blob: 08b9e8327b405823a46d831e808f54446e893344 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  | 
require "tap"
module Homebrew
  def tap
    if ARGV.empty?
      puts Tap.names
    elsif ARGV.first == "--repair"
      migrate_taps :force => true
    elsif ARGV.first == "--list-official"
      require "official_taps"
      puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
    elsif ARGV.first == "--list-pinned"
      puts Tap.select(&:pinned?).map(&:name)
    else
      tap = Tap.fetch(ARGV.named[0])
      begin
        tap.install(:clone_target => ARGV.named[1],
                    :full_clone   => ARGV.include?("--full"))
      rescue TapAlreadyTappedError => e
        opoo e
      end
    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)
    opoo "Homebrew.install_tap is deprecated, use Tap#install."
    tap = Tap.fetch(user, repo)
    begin
      tap.install(:clone_target => clone_target, :full_clone => ARGV.include?("--full"))
    rescue TapAlreadyTappedError
      false
    else
      true
    end
  end
  # Migrate tapped formulae from symlink-based to directory-based structure.
  def migrate_taps(options = {})
    ignore = HOMEBREW_LIBRARY/"Formula/.gitignore"
    return unless ignore.exist? || options.fetch(:force, false)
    (HOMEBREW_LIBRARY/"Formula").children.each { |c| c.unlink if c.symlink? }
    ignore.unlink if ignore.exist?
  end
end
  |