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

Merge pull request #1752 from alyssais/uninstalling_dependencies

keg: fix fallback dependencies with multiple kegs
parents 760a4601 b0a38c06
No related branches found
No related tags found
No related merge requests found
......@@ -87,11 +87,23 @@ class Keg
mime-info pixmaps sounds postgresql
].freeze
# Will return some kegs, and some dependencies, if they're present.
# Given an array of kegs, this method will try to find some other kegs
# that depend on them.
#
# If it does, it returns:
# - some kegs in the passed array that have installed dependents
# - some installed dependents of those kegs.
#
# If it doesn't, it returns nil.
#
# Note that nil will be returned if the only installed dependents
# in the passed kegs are other kegs in the array.
#
# For efficiency, we don't bother trying to get complete data.
def self.find_some_installed_dependents(kegs)
# First, check in the tabs of installed Formulae.
kegs.each do |keg|
# Don't include dependencies of kegs that were in the given array.
dependents = keg.installed_dependents - kegs
dependents.map! { |d| "#{d.name} #{d.version}" }
return [keg], dependents if dependents.any?
......@@ -105,7 +117,12 @@ class Keg
#
# This happens after the initial dependency check because it's sloooow.
remaining_formulae = Formula.installed.select do |f|
f.installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? }
installed_kegs = f.installed_kegs
# Don't include dependencies of kegs that were in the given array.
next false if (installed_kegs - kegs).empty?
installed_kegs.any? { |k| Tab.for_keg(k).runtime_dependencies.nil? }
end
keg_names = kegs.map(&:name)
......
......@@ -382,6 +382,13 @@ class InstalledDependantsTests < LinkTestCase
assert_equal [[@keg], ["bar"]], Keg.find_some_installed_dependents([@keg])
end
def test_uninstalling_dependent_and_dependency
dependencies nil
Formula["bar"].class.depends_on "foo"
assert_empty @keg.installed_dependents
assert_nil Keg.find_some_installed_dependents([@keg, @dependent])
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