aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dependency.rb
diff options
context:
space:
mode:
authorJack Nagel2013-06-07 22:27:30 -0500
committerJack Nagel2013-06-08 12:23:15 -0500
commit8cb861c6950bd72b0370391fade00ea60209e2b9 (patch)
tree4c07cf4dafca8fd4d45bd807782ff330670d09c6 /Library/Homebrew/dependency.rb
parent80745a97e20f8033ff6ff3a0c0425b22880a944f (diff)
downloadbrew-8cb861c6950bd72b0370391fade00ea60209e2b9.tar.bz2
Merge repeated deps with differing options
When expanding dependencies, repeated deps are treated as equal and all but the first are discarded when #uniq is called on the resulting array. However, they may have different sets of options attached, so we cannot assume they are the same. After the initial expansion, we group them by name and then create a new Dependency object for each name, merging the options from each group. Fixes Homebrew/homebrew#20335.
Diffstat (limited to 'Library/Homebrew/dependency.rb')
-rw-r--r--Library/Homebrew/dependency.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb
index f0ad27cf0..d5ae57667 100644
--- a/Library/Homebrew/dependency.rb
+++ b/Library/Homebrew/dependency.rb
@@ -70,13 +70,15 @@ class Dependency
# The default filter, which is applied when a block is not given, omits
# optionals and recommendeds based on what the dependent has asked for.
def expand(dependent, &block)
- dependent.deps.map do |dep|
+ deps = dependent.deps.map do |dep|
if prune?(dependent, dep, &block)
next
else
expand(dep.to_formula, &block) << dep
end
- end.flatten.compact.uniq
+ end.flatten.compact
+
+ merge_repeats(deps)
end
def prune?(dependent, dep, &block)
@@ -93,5 +95,13 @@ class Dependency
def prune
throw(:prune, true)
end
+
+ def merge_repeats(deps)
+ grouped = deps.group_by(&:name)
+
+ deps.uniq.map do |dep|
+ new(dep.name, grouped.fetch(dep.name).map(&:tags).flatten)
+ end
+ end
end
end