update-report: more forceful rename migration.

Migrate between different taps and delete relevant subdirectories if
they can be safely. Also, tweak some naming and use utility methods.
This commit is contained in:
Mike McQuaid 2017-03-29 11:22:59 +01:00
parent f3743e98b6
commit ffd706d997

View File

@ -502,12 +502,18 @@ class Reporter
end
def migrate_formula_rename
Formula.installed.map(&:oldname).compact.each do |old_name|
old_name_dir = HOMEBREW_CELLAR/old_name
next if old_name_dir.symlink?
next unless old_name_dir.directory? && !old_name_dir.subdirs.empty?
Formula.installed.each do |formula|
next unless Migrator.needs_migration?(formula)
new_name = tap.formula_renames[old_name]
oldname = formula.oldname
oldname_rack = HOMEBREW_CELLAR/oldname
if oldname_rack.subdirs.empty?
oldname_rack.rmdir_if_possible
next
end
new_name = tap.formula_renames[oldname]
next unless new_name
new_full_name = "#{tap}/#{new_name}"
@ -520,9 +526,8 @@ class Reporter
end
begin
migrator = Migrator.new(f)
migrator = Migrator.new(f, force: true)
migrator.migrate
rescue Migrator::MigratorDifferentTapsError
rescue Exception => e
onoe e
end