Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

fix bundle viz error with git #2046

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions lib/bundler/graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize(env, output_file, show_version = false, show_requirements = false
@node_options = {}
@edge_options = {}

_patching_gem_dependency_class
_populate_relations
end

Expand All @@ -27,7 +28,6 @@ def viz
private

def _populate_relations
relations = Hash.new {|h, k| h[k] = Set.new}
parent_dependencies = _groups.values.to_set.flatten
while true
if parent_dependencies.empty?
Expand All @@ -36,7 +36,6 @@ def _populate_relations
tmp = Set.new
parent_dependencies.each do |dependency|
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
relations[dependency.name] += child_dependencies.to_set
@relations[dependency.name] += child_dependencies.map(&:name).to_set
tmp += child_dependencies

Expand All @@ -48,7 +47,6 @@ def _populate_relations
parent_dependencies = tmp
end
end
@relations
end

def _groups
Expand Down Expand Up @@ -87,6 +85,27 @@ def _make_label(symbol_or_string_or_dependency, element_type)
label.nil? ? {} : { :label => label }
end

def _patching_gem_dependency_class
# method borrow from rubygems/dependency.rb
# redefinition of matching_specs will also redefine to_spec and to_specs
Gem::Dependency.class_eval do
def matching_specs platform_only = false
matches = Bundler.load.specs.select { |spec|
self.name === spec.name and # TODO: == instead of ===
requirement.satisfied_by? spec.version
}

if platform_only
matches.reject! { |spec|
not Gem::Platform.match spec.platform
}
end

matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
end
end
end

class GraphVizClient
def initialize(graph_instance)
@graph_name = graph_instance.class::GRAPH_NAME
Expand Down