formula: rename installed_prefix to latest_installed_prefix

This commit is contained in:
Seeker 2020-08-21 12:10:44 -07:00
parent 2b4f3646b7
commit 5acdcd26d0
7 changed files with 27 additions and 27 deletions

View File

@ -163,7 +163,7 @@ module Homebrew
Formulary.from_rack(rack)
end
unless (prefix = f.installed_prefix).directory?
unless (prefix = f.latest_installed_prefix).directory?
raise MultipleVersionsInstalledError, "#{rack.basename} has multiple installed versions"
end

View File

@ -26,7 +26,7 @@ module Homebrew
puts HOMEBREW_PREFIX
else
puts args.named.to_resolved_formulae.map { |f|
f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix
f.opt_prefix.exist? ? f.opt_prefix : f.latest_installed_prefix
}
end
end

View File

@ -488,11 +488,11 @@ class Formula
delegate compiler_failures: :active_spec
# If this {Formula} is installed.
# This is actually just a check for if the {#installed_prefix} directory
# This is actually just a check for if the {#latest_installed_prefix} directory
# exists and is not empty.
# @private
def latest_version_installed?
(dir = installed_prefix).directory? && !dir.children.empty?
(dir = latest_installed_prefix).directory? && !dir.children.empty?
end
# If at least one version of {Formula} is installed.
@ -547,7 +547,7 @@ class Formula
# The latest prefix for this formula. Checks for {#head}, then {#devel}
# and then {#stable}'s {#prefix}
# @private
def installed_prefix
def latest_installed_prefix
if head && (head_version = latest_head_version) && !head_version_outdated?(head_version)
latest_head_prefix
elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory?
@ -563,7 +563,7 @@ class Formula
# if the formula is not installed.
# @private
def installed_version
Keg.new(installed_prefix).version
Keg.new(latest_installed_prefix).version
end
# The directory in the cellar that the formula is installed to.

View File

@ -145,7 +145,7 @@ class Tab < OpenStruct
paths << dirs.first
end
paths << f.installed_prefix
paths << f.latest_installed_prefix
path = paths.map { |pn| pn/FILENAME }.find(&:file?)

View File

@ -28,17 +28,17 @@ describe Homebrew do
end
end
let(:kegs_by_rack) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } }
let(:kegs_by_rack) { { dependency.rack => [Keg.new(dependency.latest_installed_prefix)] } }
before do
[dependency, dependent].each do |f|
f.installed_prefix.mkpath
Keg.new(f.installed_prefix).optlink
f.latest_installed_prefix.mkpath
Keg.new(f.latest_installed_prefix).optlink
end
tab = Tab.empty
tab.homebrew_version = "1.1.6"
tab.tabfile = dependent.installed_prefix/Tab::FILENAME
tab.tabfile = dependent.latest_installed_prefix/Tab::FILENAME
tab.runtime_dependencies = [
{ "full_name" => "dependency", "version" => "1" },
]

View File

@ -282,23 +282,23 @@ describe Formula do
describe "#latest_version_installed?" do
let(:f) { Testball.new }
it "returns false if the #installed_prefix is not a directory" do
allow(f).to receive(:installed_prefix).and_return(double(directory?: false))
it "returns false if the #latest_installed_prefix is not a directory" do
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: false))
expect(f).not_to be_latest_version_installed
end
it "returns false if the #installed_prefix does not have children" do
allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: []))
it "returns false if the #latest_installed_prefix does not have children" do
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: true, children: []))
expect(f).not_to be_latest_version_installed
end
it "returns true if the #installed_prefix has children" do
allow(f).to receive(:installed_prefix).and_return(double(directory?: true, children: [double]))
it "returns true if the #latest_installed_prefix has children" do
allow(f).to receive(:latest_installed_prefix).and_return(double(directory?: true, children: [double]))
expect(f).to be_latest_version_installed
end
end
describe "#installed prefix" do
describe "#latest_installed_prefix" do
let(:f) do
formula do
url "foo"
@ -311,17 +311,17 @@ describe Formula do
let(:head_prefix) { HOMEBREW_CELLAR/f.name/f.head.version }
it "is the same as #prefix by default" do
expect(f.installed_prefix).to eq(f.prefix)
expect(f.latest_installed_prefix).to eq(f.prefix)
end
it "returns the stable prefix if it is installed" do
stable_prefix.mkpath
expect(f.installed_prefix).to eq(stable_prefix)
expect(f.latest_installed_prefix).to eq(stable_prefix)
end
it "returns the head prefix if it is installed" do
head_prefix.mkpath
expect(f.installed_prefix).to eq(head_prefix)
expect(f.latest_installed_prefix).to eq(head_prefix)
end
it "returns the stable prefix if head is outdated" do
@ -332,12 +332,12 @@ describe Formula do
tab.source["versions"] = { "stable" => "1.0" }
tab.write
expect(f.installed_prefix).to eq(stable_prefix)
expect(f.latest_installed_prefix).to eq(stable_prefix)
end
it "returns the head prefix if the active specification is :head" do
f.active_spec = :head
expect(f.installed_prefix).to eq(head_prefix)
expect(f.latest_installed_prefix).to eq(head_prefix)
end
end
@ -728,7 +728,7 @@ describe Formula do
dependency = formula("dependency") { url "f-1.0" }
formula.brew { formula.install }
keg = Keg.for(formula.installed_prefix)
keg = Keg.for(formula.latest_installed_prefix)
keg.link
linkage_checker = double("linkage checker", undeclared_deps: [dependency.name])
@ -745,7 +745,7 @@ describe Formula do
tab.runtime_dependencies = ["foo"]
tab.write
keg = Keg.for(formula.installed_prefix)
keg = Keg.for(formula.latest_installed_prefix)
keg.link
expect(formula.runtime_dependencies.map(&:name)).to be_empty
@ -865,7 +865,7 @@ describe Formula do
head("foo")
end
stable_prefix = f.installed_prefix
stable_prefix = f.latest_installed_prefix
stable_prefix.mkpath
[["000000_1", 1], ["111111", 2], ["111111_1", 2]].each do |pkg_version_suffix, stamp|

View File

@ -15,7 +15,7 @@ module Utils
def built_as?(f)
return false unless f.latest_version_installed?
tab = Tab.for_keg(f.installed_prefix)
tab = Tab.for_keg(f.latest_installed_prefix)
tab.built_as_bottle
end