Merge pull request #1682 from MikeMcQuaid/tap_migrations_rename

tap_migrations: support renaming to/from casks.
This commit is contained in:
Mike McQuaid 2016-12-29 14:34:56 +00:00 committed by GitHub
commit 4ca2eaf8df
2 changed files with 18 additions and 7 deletions

View File

@ -421,18 +421,27 @@ class Reporter
new_tap_name = tap.tap_migrations[name] new_tap_name = tap.tap_migrations[name]
next if new_tap_name.nil? # skip if not in tap_migrations list. next if new_tap_name.nil? # skip if not in tap_migrations list.
new_tap_user, new_tap_repo, new_tap_new_name = new_tap_name.split("/")
new_name = if new_tap_new_name
new_full_name = new_tap_new_name
new_tap_name = "#{new_tap_user}/#{new_tap_repo}"
new_tap_new_name
else
new_full_name = "#{new_tap_name}/#{name}"
name
end
# This means it is a Cask # This means it is a Cask
if report[:DC].include? full_name if report[:DC].include? full_name
next unless (HOMEBREW_PREFIX/"Caskroom"/name).exist? next unless (HOMEBREW_PREFIX/"Caskroom"/new_name).exist?
new_tap = Tap.fetch(new_tap_name) new_tap = Tap.fetch(new_tap_name)
new_tap.install unless new_tap.installed? new_tap.install unless new_tap.installed?
ohai "#{name} has been moved to Homebrew.", <<-EOS.undent ohai "#{name} has been moved to Homebrew.", <<-EOS.undent
To uninstall the cask run: To uninstall the cask run:
brew cask uninstall --force #{name} brew cask uninstall --force #{name}
EOS EOS
new_full_name = "#{new_tap_name}/#{name}" next if (HOMEBREW_CELLAR/new_name.split("/").last).directory?
next if (HOMEBREW_CELLAR/name.split("/").last).directory? ohai "Installing #{new_name}..."
ohai "Installing #{name}..."
system HOMEBREW_BREW_FILE, "install", new_full_name system HOMEBREW_BREW_FILE, "install", new_full_name
begin begin
unless Formulary.factory(new_full_name).keg_only? unless Formulary.factory(new_full_name).keg_only?
@ -456,13 +465,13 @@ class Reporter
system HOMEBREW_BREW_FILE, "uninstall", "--force", name system HOMEBREW_BREW_FILE, "uninstall", "--force", name
ohai "brew prune" ohai "brew prune"
system HOMEBREW_BREW_FILE, "prune" system HOMEBREW_BREW_FILE, "prune"
ohai "brew cask install #{name}" ohai "brew cask install #{new_name}"
system HOMEBREW_BREW_FILE, "cask", "install", name system HOMEBREW_BREW_FILE, "cask", "install", new_name
else else
ohai "#{name} has been moved to Homebrew-Cask.", <<-EOS.undent ohai "#{name} has been moved to Homebrew-Cask.", <<-EOS.undent
To uninstall the formula and install the cask run: To uninstall the formula and install the cask run:
brew uninstall --force #{name} brew uninstall --force #{name}
brew cask install #{name} brew cask install #{new_name}
EOS EOS
end end
else else

View File

@ -186,6 +186,8 @@ class Formulary
name = new_name name = new_name
new_name = @tap.core_tap? ? name : "#{@tap}/#{name}" new_name = @tap.core_tap? ? name : "#{@tap}/#{name}"
elsif (new_tap_name = @tap.tap_migrations[name]) elsif (new_tap_name = @tap.tap_migrations[name])
new_tap_user, new_tap_repo, = new_tap_name.split("/")
new_tap_name = "#{new_tap_user}/#{new_tap_repo}"
new_tap = Tap.fetch new_tap_name new_tap = Tap.fetch new_tap_name
new_tap.install unless new_tap.installed? new_tap.install unless new_tap.installed?
new_tapped_name = "#{new_tap_name}/#{name}" new_tapped_name = "#{new_tap_name}/#{name}"