Skip to content
Snippets Groups Projects
Commit ad593cf4 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #1757 from alyssais/moved_formula

keg: handle dependencies of moved/renamed formulae
parents 4b5489e1 524d9ce8
No related branches found
Tags 1.2.1
No related merge requests found
......@@ -126,7 +126,18 @@ class Keg
end
keg_names = kegs.map(&:name)
kegs_by_source = kegs.group_by { |k| [k.name, Tab.for_keg(k).tap] }
kegs_by_source = kegs.group_by do |keg|
begin
# First, attempt to resolve the keg to a formula
# to get up-to-date name and tap information.
f = keg.to_formula
[f.name, f.tap]
rescue FormulaUnavailableError
# If the formula for the keg can't be found,
# fall back to the information in the tab.
[keg.name, Tab.for_keg(keg).tap]
end
end
remaining_formulae.each do |dependent|
required = dependent.missing_dependencies(hide: keg_names)
......
......@@ -373,9 +373,15 @@ class InstalledDependantsTests < LinkTestCase
t.source["tap"] = "some/tap"
t.source["path"] = nil
end
dependencies [{ "full_name" => "some/tap/foo", "version" => "1.0" }]
assert_equal [@dependent], @keg.installed_dependents
assert_equal [[@keg], ["bar 1.0"]], Keg.find_some_installed_dependents([@keg])
dependencies nil
# It doesn't make sense for a keg with no formula to have any dependents,
# so that can't really be tested.
assert_nil Keg.find_some_installed_dependents([@keg])
end
def test_a_dependency_with_no_tap_in_tab
......@@ -388,7 +394,7 @@ class InstalledDependantsTests < LinkTestCase
Formula["bar"].class.depends_on "baz"
result = Keg.find_some_installed_dependents([@keg, @tap_dep])
assert_equal [[@tap_dep], ["bar"]], result
assert_equal [[@keg, @tap_dep], ["bar"]], result
end
def test_no_dependencies_anywhere
......@@ -411,6 +417,23 @@ class InstalledDependantsTests < LinkTestCase
assert_nil Keg.find_some_installed_dependents([@keg, @dependent])
end
def test_renamed_dependency
dependencies nil
stub_formula_loader Formula["foo"], "homebrew/core/foo-old"
renamed_path = HOMEBREW_CELLAR/"foo-old"
(HOMEBREW_CELLAR/"foo").rename(renamed_path)
renamed_keg = Keg.new(renamed_path.join("1.0"))
Formula["bar"].class.depends_on "foo"
result = Keg.find_some_installed_dependents([renamed_keg])
assert_equal [[renamed_keg], ["bar"]], result
ensure
# Move it back to where it was so it'll be cleaned up.
(HOMEBREW_CELLAR/"foo-old").rename(HOMEBREW_CELLAR/"foo")
end
def test_empty_dependencies_in_tab
dependencies []
assert_empty @keg.installed_dependents
......
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