outdated: check if formula needs to be migrated.

Closes Homebrew/homebrew#42938.
This commit is contained in:
Mike McQuaid 2015-08-14 14:50:26 +01:00
parent 3d7c38c736
commit 49dce3e7ae
2 changed files with 17 additions and 0 deletions

View File

@ -1,5 +1,6 @@
require "formula"
require "keg"
require "migrator"
module Homebrew
def outdated
@ -16,6 +17,13 @@ module Homebrew
formulae.map do |f|
all_versions = []
older_or_same_tap_versions = []
if f.oldname && !f.rack.exist?
if Pathname.new("#{HOMEBREW_CELLAR}/#{f.oldname}").exist?
raise Migrator::MigrationNeededError.new(f)
end
end
f.rack.subdirs.each do |dir|
keg = Keg.new dir
version = keg.version

View File

@ -4,6 +4,15 @@ require "tab"
require "tap_migrations"
class Migrator
class MigrationNeededError < RuntimeError
def initialize(formula)
super <<-EOS.undent
#{formula.oldname} was renamed to #{formula.name} and needs to be migrated.
Please run `brew migrate #{formula.oldname}`
EOS
end
end
class MigratorNoOldnameError < RuntimeError
def initialize(formula)
super "#{formula.name} doesn't replace any formula."