Skip to content
Snippets Groups Projects
Commit 769d89de authored by Markus Reiter's avatar Markus Reiter
Browse files

Resolve formulae in `brew cleanup`.

parent ca86f070
No related branches found
No related tags found
No related merge requests found
......@@ -166,7 +166,7 @@ module Homebrew
else
args.each do |arg|
formula = begin
Formula[arg]
Formulary.resolve(arg)
rescue FormulaUnavailableError, TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
nil
end
......
......@@ -54,35 +54,7 @@ module HomebrewArgvExtension
def resolved_formulae
require "formula"
@resolved_formulae ||= (downcased_unique_named - casks).map do |name|
if name.include?("/") || File.exist?(name)
f = Formulary.factory(name, spec)
if f.any_version_installed?
tab = Tab.for_formula(f)
resolved_spec = spec(nil) || tab.spec
f.active_spec = resolved_spec if f.send(resolved_spec)
f.build = tab
if f.head? && tab.tabfile
k = Keg.new(tab.tabfile.parent)
f.version.update_commit(k.version.version.commit) if k.version.head?
end
end
else
rack = Formulary.to_rack(name)
alias_path = Formulary.factory(name).alias_path
f = Formulary.from_rack(rack, spec(nil), alias_path: alias_path)
end
# If this formula was installed with an alias that has since changed,
# then it was specified explicitly in ARGV. (Using the alias would
# instead have found the new formula.)
#
# Because of this, the user is referring to this specific formula,
# not any formula targetted by the same alias, so in this context
# the formula shouldn't be considered outdated if the alias used to
# install it has changed.
f.follow_installed_alias = false
f
Formulary.resolve(name, spec: spec(nil))
end.uniq(&:name)
end
......
......@@ -47,6 +47,38 @@ module Formulary
cache[path] = klass
end
def self.resolve(name, spec: nil)
if name.include?("/") || File.exist?(name)
f = factory(name, *spec)
if f.any_version_installed?
tab = Tab.for_formula(f)
resolved_spec = spec || tab.spec
f.active_spec = resolved_spec if f.send(resolved_spec)
f.build = tab
if f.head? && tab.tabfile
k = Keg.new(tab.tabfile.parent)
f.version.update_commit(k.version.version.commit) if k.version.head?
end
end
else
rack = to_rack(name)
alias_path = factory(name).alias_path
f = from_rack(rack, *spec, alias_path: alias_path)
end
# If this formula was installed with an alias that has since changed,
# then it was specified explicitly in ARGV. (Using the alias would
# instead have found the new formula.)
#
# Because of this, the user is referring to this specific formula,
# not any formula targetted by the same alias, so in this context
# the formula shouldn't be considered outdated if the alias used to
# install it has changed.
f.follow_installed_alias = false
f
end
def self.ensure_utf8_encoding(io)
io.set_encoding(Encoding::UTF_8)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment