update: add formula renames to report

This commit is contained in:
Vlad Shablinsky 2015-08-17 21:49:55 +03:00 committed by Xu Cheng
parent 896848dd87
commit e4480cf6bf

View File

@ -62,27 +62,18 @@ module Homebrew
tabs.each(&:write)
end if load_tap_migrations
# Migrate installed renamed formulae from main Homebrew repository.
if load_formula_renames
report.select_formula(:D).each do |oldname|
newname = FORMULA_RENAMES[oldname]
next unless newname
next unless (dir = HOMEBREW_CELLAR/oldname).directory? && !dir.subdirs.empty?
load_formula_renames
report.update_renamed
begin
migrator = Migrator.new(Formulary.factory("homebrew/homebrew/#{newname}"))
migrator.migrate
rescue Migrator::MigratorDifferentTapsError
end
end
end
# Migrate installed renamed formulae from taps
report.select_formula(:D).each do |oldname|
# Migrate installed renamed formulae from core and taps.
report.select_formula(:R).each do |oldname, newname|
if oldname.include?("/")
user, repo, oldname = oldname.split("/", 3)
next unless user && repo && oldname
tap = Tap.new(user, repo)
next unless newname = tap.formula_renames[oldname]
newname = newname.split("/", 3).last
else
user, repo = "homebrew", "homebrew"
end
next unless (dir = HOMEBREW_CELLAR/oldname).directory? && !dir.subdirs.empty?
begin
@ -322,14 +313,45 @@ class Report
dump_formula_report :A, "New Formulae"
dump_formula_report :M, "Updated Formulae"
dump_formula_report :R, "Renamed Formulae"
dump_formula_report :D, "Deleted Formulae"
end
def select_formula(key)
fetch(key, []).map do |path|
def update_renamed
@hash[:R] ||= []
fetch(:D, []).each do |path|
case path.to_s
when HOMEBREW_TAP_PATH_REGEX
"#{$1}/#{$2.sub("homebrew-", "")}/#{path.basename(".rb")}"
user = $1
repo = $2.sub("homebrew-", "")
oldname = path.basename(".rb").to_s
next unless newname = Tap.new(user, repo).formula_renames[oldname]
else
oldname = path.basename(".rb").to_s
next unless newname = FORMULA_RENAMES[oldname]
end
if fetch(:A, []).include?(newpath = path.dirname.join("#{newname}.rb"))
@hash[:R] << [path, newpath]
end
end
@hash[:A] -= @hash[:R].map(&:last) if @hash[:A]
@hash[:D] -= @hash[:R].map(&:first) if @hash[:D]
end
def select_formula(key)
fetch(key, []).map do |path, newpath|
if path.to_s =~ HOMEBREW_TAP_PATH_REGEX
tap = "#{$1}/#{$2.sub("homebrew-", "")}"
if newpath
["#{tap}/#{path.basename(".rb")}", "#{tap}/#{newpath.basename(".rb")}"]
else
"#{tap}/#{path.basename(".rb")}"
end
elsif newpath
["#{path.basename(".rb")}", "#{newpath.basename(".rb")}"]
else
path.basename(".rb").to_s
end
@ -338,6 +360,7 @@ class Report
def dump_formula_report(key, title)
formula = select_formula(key)
formula.map! { |oldname, newname| "#{oldname} -> #{newname}" } if key == :R
unless formula.empty?
ohai title
puts_columns formula