From d7689fc260701f49a153882d8502385d4e4ddded Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 18 Jul 2023 09:10:02 +0100 Subject: [PATCH] Fully use Formula#oldnames Follow up from #1225 that handles multiple oldnames. --- lib/bundle/brew_dumper.rb | 16 +++++++++------- spec/bundle/brew_dumper_spec.rb | 9 +++------ spec/stub/formula.rb | 4 ---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/bundle/brew_dumper.rb b/lib/bundle/brew_dumper.rb index 583d71b67..1bef9af60 100644 --- a/lib/bundle/brew_dumper.rb +++ b/lib/bundle/brew_dumper.rb @@ -95,13 +95,15 @@ def formula_oldnames @formula_oldnames = {} formulae.each do |f| - oldname = f[:oldname] - next if oldname.blank? + oldnames = f[:oldnames] + next if oldnames.blank? - @formula_oldnames[oldname] = f[:full_name] - if f[:full_name].include? "/" # tap formula - tap_name = f[:full_name].rpartition("/").first - @formula_oldnames["#{tap_name}/#{oldname}"] = f[:full_name] + oldnames.each do |oldname| + @formula_oldnames[oldname] = f[:full_name] + if f[:full_name].include? "/" # tap formula + tap_name = f[:full_name].rpartition("/").first + @formula_oldnames["#{tap_name}/#{oldname}"] = f[:full_name] + end end end @formula_oldnames @@ -157,7 +159,7 @@ def formula_to_hash(formula) { name: formula.name, desc: formula.desc, - oldname: formula.oldnames.first, + oldnames: formula.oldnames, full_name: formula.full_name, aliases: formula.aliases, any_version_installed?: formula.any_version_installed?, diff --git a/spec/bundle/brew_dumper_spec.rb b/spec/bundle/brew_dumper_spec.rb index 43e087610..76e8c56a6 100644 --- a/spec/bundle/brew_dumper_spec.rb +++ b/spec/bundle/brew_dumper_spec.rb @@ -13,7 +13,6 @@ instance_double(Formula, name: "foo", desc: "foobar", - oldname: "oldfoo", oldnames: ["oldfoo"], full_name: "qux/quuz/foo", any_version_installed?: true, @@ -45,7 +44,7 @@ installed_on_request?: false, link?: nil, name: "foo", - oldname: "oldfoo", + oldnames: ["oldfoo"], outdated?: false, pinned?: false, poured_from_bottle?: false, @@ -58,7 +57,6 @@ instance_double(Formula, name: "bar", desc: "barfoo", - oldname: nil, oldnames: [], full_name: "bar", any_version_installed?: true, @@ -108,7 +106,7 @@ installed_on_request?: false, link?: nil, name: "bar", - oldname: nil, + oldnames: [], outdated?: true, pinned?: true, poured_from_bottle?: true, @@ -120,7 +118,6 @@ instance_double(Formula, name: "baz", desc: "", - oldname: nil, oldnames: [], full_name: "bazzles/bizzles/baz", any_version_installed?: true, @@ -152,7 +149,7 @@ installed_on_request?: false, link?: false, name: "baz", - oldname: nil, + oldnames: [], outdated?: false, pinned?: false, poured_from_bottle?: false, diff --git a/spec/stub/formula.rb b/spec/stub/formula.rb index 7f7cc857e..3022d948e 100644 --- a/spec/stub/formula.rb +++ b/spec/stub/formula.rb @@ -58,10 +58,6 @@ def desc "" end - def oldname - nil - end - def oldnames [] end