Skip to content

Commit

Permalink
Revert "uses: properly handle untapped formulae in recursive dependen…
Browse files Browse the repository at this point in the history
…cy expansion"
  • Loading branch information
MikeMcQuaid committed Jan 7, 2017
1 parent 2aac904 commit dc9819b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 43 deletions.
73 changes: 36 additions & 37 deletions Library/Homebrew/cmd/uses.rb
Expand Up @@ -47,49 +47,48 @@ def uses

uses = formulae.select do |f|
used_formulae.all? do |ff|
if recursive
deps = f.recursive_dependencies do |dependent, dep|
if dep.recommended?
Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
elsif dep.optional?
Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.build?
Dependency.prune unless includes.include?("build?")
begin
if recursive
deps = f.recursive_dependencies do |dependent, dep|
if dep.recommended?
Dependency.prune if ignores.include?("recommended?") || dependent.build.without?(dep)
elsif dep.optional?
Dependency.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.build?
Dependency.prune unless includes.include?("build?")
end
end

# If a tap isn't installed, we can't find the dependencies of one
# its formulae, and an exception will be thrown if we try.
if dep.is_a?(TapDependency) && !dep.tap.installed?
Dependency.keep_but_prune_recursive_deps
reqs = f.recursive_requirements do |dependent, req|
if req.recommended?
Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req)
elsif req.optional?
Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req)
elsif req.build?
Requirement.prune unless includes.include?("build?")
end
end
end
reqs = f.recursive_requirements do |dependent, req|
if req.recommended?
Requirement.prune if ignores.include?("recommended?") || dependent.build.without?(req)
elsif req.optional?
Requirement.prune if !includes.include?("optional?") && !dependent.build.with?(req)
elsif req.build?
Requirement.prune unless includes.include?("build?")
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
end
reqs = f.requirements.reject do |req|
ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
end
end
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
end
reqs = f.requirements.reject do |req|
ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
end
end
next true if deps.any? do |dep|
begin
dep.to_formula.full_name == ff.full_name
rescue
dep.name == ff.name
next true if deps.any? do |dep|
begin
dep.to_formula.full_name == ff.full_name
rescue
dep.name == ff.name
end
end
end

reqs.any? do |req|
req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula)
reqs.any? do |req|
req.name == ff.name || [ff.name, ff.full_name].include?(req.default_formula)
end
rescue FormulaUnavailableError
# Silently ignore this case as we don't care about things used in
# taps that aren't currently tapped.
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dependency.rb
Expand Up @@ -175,7 +175,7 @@ class TapDependency < Dependency
attr_reader :tap

def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last])
@tap = Tap.fetch(name.rpartition("/").first)
@tap = name.rpartition("/").first
super(name, tags, env_proc, option_names)
end

Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/test/dependency_test.rb
Expand Up @@ -118,11 +118,6 @@ def test_equality
end

class TapDependencyTests < Homebrew::TestCase
def test_tap
dep = TapDependency.new("foo/bar/dog")
assert_equal Tap.new("foo", "bar"), dep.tap
end

def test_option_names
dep = TapDependency.new("foo/bar/dog")
assert_equal %w[dog], dep.option_names
Expand Down

0 comments on commit dc9819b

Please sign in to comment.