aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/migrate.rb
blob: 27ca5261f9fa49f2ec39a517ea715254491d0321 (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
#:  * `migrate` [`--force`] <formulae>:
#:    Migrate renamed packages to new name, where <formulae> are old names of
#:    packages.
#:
#:    If `--force` is passed, then treat installed <formulae> and passed <formulae>
#:    like if they are from same taps and migrate them anyway.

require "migrator"

module Homebrew
  def migrate
    raise FormulaUnspecifiedError if ARGV.named.empty?

    ARGV.resolved_formulae.each do |f|
      if f.oldname
        unless (rack = HOMEBREW_CELLAR/f.oldname).exist? && !rack.subdirs.empty?
          raise NoSuchKegError, f.oldname
        end
        raise "#{rack} is a symlink" if rack.symlink?
      end

      migrator = Migrator.new(f)
      migrator.migrate
    end
  end
end