Skip to content

Commit

Permalink
Merge pull request #1230 from Homebrew/oldnames
Browse files Browse the repository at this point in the history
Fully use Formula#oldnames
  • Loading branch information
MikeMcQuaid committed Jul 18, 2023
2 parents 2ab409b + d7689fc commit 437c67d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
16 changes: 9 additions & 7 deletions lib/bundle/brew_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?,
Expand Down
9 changes: 3 additions & 6 deletions spec/bundle/brew_dumper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
instance_double(Formula,
name: "foo",
desc: "foobar",
oldname: "oldfoo",
oldnames: ["oldfoo"],
full_name: "qux/quuz/foo",
any_version_installed?: true,
Expand Down Expand Up @@ -45,7 +44,7 @@
installed_on_request?: false,
link?: nil,
name: "foo",
oldname: "oldfoo",
oldnames: ["oldfoo"],
outdated?: false,
pinned?: false,
poured_from_bottle?: false,
Expand All @@ -58,7 +57,6 @@
instance_double(Formula,
name: "bar",
desc: "barfoo",
oldname: nil,
oldnames: [],
full_name: "bar",
any_version_installed?: true,
Expand Down Expand Up @@ -108,7 +106,7 @@
installed_on_request?: false,
link?: nil,
name: "bar",
oldname: nil,
oldnames: [],
outdated?: true,
pinned?: true,
poured_from_bottle?: true,
Expand All @@ -120,7 +118,6 @@
instance_double(Formula,
name: "baz",
desc: "",
oldname: nil,
oldnames: [],
full_name: "bazzles/bizzles/baz",
any_version_installed?: true,
Expand Down Expand Up @@ -152,7 +149,7 @@
installed_on_request?: false,
link?: false,
name: "baz",
oldname: nil,
oldnames: [],
outdated?: false,
pinned?: false,
poured_from_bottle?: false,
Expand Down
4 changes: 0 additions & 4 deletions spec/stub/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ def desc
""
end

def oldname
nil
end

def oldnames
[]
end
Expand Down

0 comments on commit 437c67d

Please sign in to comment.