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