Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formula: fix alias loading #14849

Merged
merged 1 commit into from Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Expand Up @@ -1417,7 +1417,7 @@ def new_formula_available?
end

def current_installed_alias_target
Formulary.factory(installed_alias_path) if installed_alias_path
Formulary.factory(installed_alias_name) if installed_alias_path
end

# Has the target of the alias used to install this formula changed?
Expand Down
16 changes: 9 additions & 7 deletions Library/Homebrew/test/formula_spec.rb
Expand Up @@ -1194,6 +1194,7 @@ def pour_bottle?

let(:tab) { Tab.empty }
let(:alias_path) { "#{CoreTap.instance.alias_dir}/bar" }
let(:alias_name) { "bar" }

before do
allow(described_class).to receive(:installed).and_return([f])
Expand All @@ -1215,7 +1216,7 @@ def pour_bottle?

specify "alias changes when not changed" do
tab.source["path"] = alias_path
stub_formula_loader(f, alias_path)
stub_formula_loader(f, alias_name)

CoreTap.instance.alias_dir.mkpath
FileUtils.ln_sf f.path, alias_path
Expand All @@ -1230,7 +1231,7 @@ def pour_bottle?

specify "alias changes when new alias target" do
tab.source["path"] = alias_path
stub_formula_loader(new_formula, alias_path)
stub_formula_loader(new_formula, alias_name)

CoreTap.instance.alias_dir.mkpath
FileUtils.ln_sf new_formula.path, alias_path
Expand All @@ -1245,7 +1246,7 @@ def pour_bottle?

specify "alias changes when old formulae installed" do
tab.source["path"] = alias_path
stub_formula_loader(new_formula, alias_path)
stub_formula_loader(new_formula, alias_name)

CoreTap.instance.alias_dir.mkpath
FileUtils.ln_sf new_formula.path, alias_path
Expand Down Expand Up @@ -1286,6 +1287,7 @@ def pour_bottle?
end

let(:alias_path) { "#{f.tap.alias_dir}/bar" }
let(:alias_name) { "bar" }

def setup_tab_for_prefix(prefix, options = {})
prefix.mkpath
Expand Down Expand Up @@ -1324,14 +1326,14 @@ def setup_tab_for_prefix(prefix, options = {})
example "outdated follow alias and alias unchanged" do
f.follow_installed_alias = true
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
stub_formula_loader(f, alias_path)
stub_formula_loader(f, alias_name)
expect(f.outdated_kegs).to be_empty
end

example "outdated follow alias and alias changed and new target not installed" do
f.follow_installed_alias = true
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
stub_formula_loader(new_formula, alias_path)
stub_formula_loader(new_formula, alias_name)

CoreTap.instance.alias_dir.mkpath
FileUtils.ln_sf new_formula.path, alias_path
Expand All @@ -1342,15 +1344,15 @@ def setup_tab_for_prefix(prefix, options = {})
example "outdated follow alias and alias changed and new target installed" do
f.follow_installed_alias = true
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
stub_formula_loader(new_formula, alias_path)
stub_formula_loader(new_formula, alias_name)
setup_tab_for_prefix(new_formula.prefix)
expect(f.outdated_kegs).to be_empty
end

example "outdated no follow alias and alias unchanged" do
f.follow_installed_alias = false
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
stub_formula_loader(f, alias_path)
stub_formula_loader(f, alias_name)
expect(f.outdated_kegs).to be_empty
end

Expand Down