Merge pull request #12105 from Bo98/specified_path-fix

formula: fix error in Formula#specified_path with aliases
This commit is contained in:
Bo Anderson 2021-09-22 02:31:29 +01:00 committed by GitHub
commit 4952f7d06f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -310,7 +310,8 @@ class Formula
# The path that was specified to find this formula.
def specified_path
default_specified_path = alias_path || path
default_specified_path = Pathname(alias_path) if alias_path.present?
default_specified_path ||= path
return default_specified_path if default_specified_path.presence&.exist?
return local_bottle_path if local_bottle_path.presence&.exist?

View File

@ -28,7 +28,7 @@ describe Formula do
let(:path) { Formulary.core_path(name) }
let(:spec) { :stable }
let(:alias_name) { "baz@1" }
let(:alias_path) { CoreTap.instance.alias_dir/alias_name }
let(:alias_path) { (CoreTap.instance.alias_dir/alias_name).to_s }
let(:f) { klass.new(name, path, spec) }
let(:f_alias) { klass.new(name, path, spec, alias_path: alias_path) }
@ -41,6 +41,7 @@ describe Formula do
expect(f.alias_path).to be nil
expect(f.alias_name).to be nil
expect(f.full_alias_name).to be nil
expect(f.specified_path).to eq(path)
expect { klass.new }.to raise_error(ArgumentError)
end
@ -51,6 +52,7 @@ describe Formula do
expect(f_alias.alias_path).to eq(alias_path)
expect(f_alias.alias_name).to eq(alias_name)
expect(f_alias.specified_name).to eq(alias_name)
expect(f_alias.specified_path).to eq(Pathname(alias_path))
expect(f_alias.full_alias_name).to eq(alias_name)
expect(f_alias.full_specified_name).to eq(alias_name)
expect { klass.new }.to raise_error(ArgumentError)
@ -71,6 +73,7 @@ describe Formula do
expect(f.alias_path).to be nil
expect(f.alias_name).to be nil
expect(f.full_alias_name).to be nil
expect(f.specified_path).to eq(path)
expect { klass.new }.to raise_error(ArgumentError)
end
@ -81,6 +84,7 @@ describe Formula do
expect(f_alias.alias_path).to eq(alias_path)
expect(f_alias.alias_name).to eq(alias_name)
expect(f_alias.specified_name).to eq(alias_name)
expect(f_alias.specified_path).to eq(Pathname(alias_path))
expect(f_alias.full_alias_name).to eq(full_alias_name)
expect(f_alias.full_specified_name).to eq(full_alias_name)
expect { klass.new }.to raise_error(ArgumentError)