Merge pull request #2421 from MikeMcQuaid/formula-check-alias-exists
formula: check installed_alias_path exists.
This commit is contained in:
commit
a582be06c2
@ -252,12 +252,14 @@ class Formula
|
|||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
# The alias path that was used to install this formula, if present.
|
# The alias path that was used to install this formula, if it exists.
|
||||||
# Can differ from alias_path, which is the alias used to find the formula,
|
# Can differ from alias_path, which is the alias used to find the formula,
|
||||||
# and is specified to this instance.
|
# and is specified to this instance.
|
||||||
def installed_alias_path
|
def installed_alias_path
|
||||||
path = build.source["path"] if build.is_a?(Tab)
|
path = build.source["path"] if build.is_a?(Tab)
|
||||||
path if path =~ %r{#{HOMEBREW_TAP_DIR_REGEX}/Aliases}
|
return unless path =~ %r{#{HOMEBREW_TAP_DIR_REGEX}/Aliases}
|
||||||
|
return unless File.symlink?(path)
|
||||||
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed_alias_name
|
def installed_alias_name
|
||||||
|
@ -129,6 +129,8 @@ describe Formula do
|
|||||||
|
|
||||||
alias_name = "bar"
|
alias_name = "bar"
|
||||||
alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
|
alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf f.path, alias_path
|
||||||
|
|
||||||
f.build = Tab.new(source: { "path" => alias_path })
|
f.build = Tab.new(source: { "path" => alias_path })
|
||||||
|
|
||||||
@ -160,6 +162,8 @@ describe Formula do
|
|||||||
alias_name = "bar"
|
alias_name = "bar"
|
||||||
full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
|
full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
|
||||||
alias_path = "#{tap.alias_dir}/#{alias_name}"
|
alias_path = "#{tap.alias_dir}/#{alias_name}"
|
||||||
|
tap.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf f.path, alias_path
|
||||||
|
|
||||||
f.build = Tab.new(source: { "path" => alias_path })
|
f.build = Tab.new(source: { "path" => alias_path })
|
||||||
|
|
||||||
@ -168,6 +172,8 @@ describe Formula do
|
|||||||
expect(f.full_installed_alias_name).to eq(full_alias_name)
|
expect(f.full_installed_alias_name).to eq(full_alias_name)
|
||||||
expect(f.installed_specified_name).to eq(alias_name)
|
expect(f.installed_specified_name).to eq(alias_name)
|
||||||
expect(f.full_installed_specified_name).to eq(full_alias_name)
|
expect(f.full_installed_specified_name).to eq(full_alias_name)
|
||||||
|
|
||||||
|
FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/user"
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#prefix" do
|
specify "#prefix" do
|
||||||
@ -402,6 +408,8 @@ describe Formula do
|
|||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
end
|
end
|
||||||
f.build = Tab.new(source: { "path" => source_path.to_s })
|
f.build = Tab.new(source: { "path" => source_path.to_s })
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf f.path, source_path
|
||||||
|
|
||||||
expect(f.alias_path).to eq(alias_path)
|
expect(f.alias_path).to eq(alias_path)
|
||||||
expect(f.installed_alias_path).to eq(source_path.to_s)
|
expect(f.installed_alias_path).to eq(source_path.to_s)
|
||||||
@ -443,6 +451,9 @@ describe Formula do
|
|||||||
|
|
||||||
allow(described_class).to receive(:installed).and_return(formulae)
|
allow(described_class).to receive(:installed).and_return(formulae)
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf formula_with_alias.path, alias_path
|
||||||
|
|
||||||
expect(described_class.installed_with_alias_path(alias_path))
|
expect(described_class.installed_with_alias_path(alias_path))
|
||||||
.to eq([formula_with_alias])
|
.to eq([formula_with_alias])
|
||||||
end
|
end
|
||||||
@ -940,6 +951,9 @@ describe Formula do
|
|||||||
tab.source["path"] = alias_path
|
tab.source["path"] = alias_path
|
||||||
stub_formula_loader(f, alias_path)
|
stub_formula_loader(f, alias_path)
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf f.path, alias_path
|
||||||
|
|
||||||
expect(f.current_installed_alias_target).to eq(f)
|
expect(f.current_installed_alias_target).to eq(f)
|
||||||
expect(f.latest_formula).to eq(f)
|
expect(f.latest_formula).to eq(f)
|
||||||
expect(f).not_to have_changed_installed_alias_target
|
expect(f).not_to have_changed_installed_alias_target
|
||||||
@ -952,6 +966,9 @@ describe Formula do
|
|||||||
tab.source["path"] = alias_path
|
tab.source["path"] = alias_path
|
||||||
stub_formula_loader(new_formula, alias_path)
|
stub_formula_loader(new_formula, alias_path)
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf new_formula.path, alias_path
|
||||||
|
|
||||||
expect(f.current_installed_alias_target).to eq(new_formula)
|
expect(f.current_installed_alias_target).to eq(new_formula)
|
||||||
expect(f.latest_formula).to eq(new_formula)
|
expect(f.latest_formula).to eq(new_formula)
|
||||||
expect(f).to have_changed_installed_alias_target
|
expect(f).to have_changed_installed_alias_target
|
||||||
@ -964,6 +981,9 @@ describe Formula do
|
|||||||
tab.source["path"] = alias_path
|
tab.source["path"] = alias_path
|
||||||
stub_formula_loader(new_formula, alias_path)
|
stub_formula_loader(new_formula, alias_path)
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf new_formula.path, alias_path
|
||||||
|
|
||||||
expect(new_formula.current_installed_alias_target).to eq(new_formula)
|
expect(new_formula.current_installed_alias_target).to eq(new_formula)
|
||||||
expect(new_formula.latest_formula).to eq(new_formula)
|
expect(new_formula.latest_formula).to eq(new_formula)
|
||||||
expect(new_formula).not_to have_changed_installed_alias_target
|
expect(new_formula).not_to have_changed_installed_alias_target
|
||||||
@ -1050,6 +1070,10 @@ describe Formula do
|
|||||||
f.follow_installed_alias = true
|
f.follow_installed_alias = true
|
||||||
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
|
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
|
||||||
stub_formula_loader(new_formula, alias_path)
|
stub_formula_loader(new_formula, alias_path)
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf new_formula.path, alias_path
|
||||||
|
|
||||||
expect(f.outdated_kegs).not_to be_empty
|
expect(f.outdated_kegs).not_to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1088,6 +1112,10 @@ describe Formula do
|
|||||||
tab = setup_tab_for_prefix(old_alias_target_prefix, path: alias_path)
|
tab = setup_tab_for_prefix(old_alias_target_prefix, path: alias_path)
|
||||||
old_formula.build = tab
|
old_formula.build = tab
|
||||||
allow(described_class).to receive(:installed).and_return([old_formula])
|
allow(described_class).to receive(:installed).and_return([old_formula])
|
||||||
|
|
||||||
|
CoreTap.instance.alias_dir.mkpath
|
||||||
|
FileUtils.ln_sf f.path, alias_path
|
||||||
|
|
||||||
expect(f.outdated_kegs).not_to be_empty
|
expect(f.outdated_kegs).not_to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user