summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Rafaniello <jrafanie@redhat.com>2016-06-14 17:40:56 -0400
committerJoe Rafaniello <jrafanie@redhat.com>2016-06-17 12:57:28 -0400
commit8920da0e6610ed2a1ce52c7ec66fa5a91bbb6a2a (patch)
tree38215ac2a30d80a100566597855fc581a62ce0c0
parente45c11f34b350ac74d661b03927e8345c2f7da4c (diff)
downloadbundler-8920da0e6610ed2a1ce52c7ec66fa5a91bbb6a2a.tar.gz
Use Set equality for path gems to avoid unneeded re-resolution.
- For comparing source dependencies to locked source dependencies - For comparing two Bundler::Index dependencies Added test case. Fixed bad tests cases hidden by the above bug: - 'foo' depended on rack but we didn't build 'rack' in the path - We couldn't find 'bar' built into 'foo/bar' because the :path only had 'foo'
-rw-r--r--lib/bundler/definition.rb4
-rw-r--r--lib/bundler/index.rb2
-rw-r--r--spec/bundler/definition_spec.rb2
-rw-r--r--spec/install/gemfile/path_spec.rb39
4 files changed, 42 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index d4af6b70e7..852f343509 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -216,9 +216,11 @@ module Bundler
@resolve ||= begin
last_resolve = converge_locked_specs
if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?)
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
last_resolve
else
# Run a resolve against the locally available gems
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies")
last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version)
end
end
@@ -487,7 +489,7 @@ module Bundler
deps_for_source = @dependencies.select {|s| s.source == source }
locked_deps_for_source = @locked_deps.select {|s| s.source == source }
- deps_for_source != locked_deps_for_source
+ Set.new(deps_for_source) != Set.new(locked_deps_for_source)
end
# Get all locals and override their matching sources.
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index c28a120990..d150fafb04 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -134,7 +134,7 @@ module Bundler
def ==(other)
all? do |spec|
other_spec = other[spec].first
- other_spec && (spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
+ other_spec && Set.new(spec.dependencies) == Set.new(other_spec.dependencies) && spec.source == other_spec.source
end
end
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb
index 443a2c9703..6e347dbdc2 100644
--- a/spec/bundler/definition_spec.rb
+++ b/spec/bundler/definition_spec.rb
@@ -6,7 +6,7 @@ describe Bundler::Definition do
before do
allow(Bundler).to receive(:settings) { Bundler::Settings.new(".") }
allow(Bundler).to receive(:default_gemfile) { Pathname.new("Gemfile") }
- allow(Bundler).to receive(:ui) { double("UI", :info => "") }
+ allow(Bundler).to receive(:ui) { double("UI", :info => "", :debug => "") }
end
describe "#lock" do
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 64919370be..de4e80cb6a 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -363,6 +363,40 @@ describe "bundle install with explicit source paths" do
expect(exitstatus).to eq(0) if exitstatus
end
+ context "existing lockfile" do
+ it "rubygems gems don't re-resolve without changes" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'rack-obama', '1.0'
+ gem 'net-ssh', '1.0'
+ G
+
+ bundle :check, :env => { "DEBUG" => 1 }
+ expect(out).to match(/using resolution from the lockfile/)
+ should_be_installed "rack-obama 1.0", "net-ssh 1.0"
+ end
+
+ it "source path gems w/deps don't re-resolve without changes" do
+ build_lib "rack-obama", "1.0", :path => lib_path("omg") do |s|
+ s.add_dependency "yard"
+ end
+
+ build_lib "net-ssh", "1.0", :path => lib_path("omg") do |s|
+ s.add_dependency "yard"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem 'rack-obama', :path => "#{lib_path("omg")}"
+ gem 'net-ssh', :path => "#{lib_path("omg")}"
+ G
+
+ bundle :check, :env => { "DEBUG" => 1 }
+ expect(out).to match(/using resolution from the lockfile/)
+ should_be_installed "rack-obama 1.0", "net-ssh 1.0"
+ end
+ end
+
it "installs executable stubs" do
build_lib "foo" do |s|
s.executables = ["foo"]
@@ -381,7 +415,7 @@ describe "bundle install with explicit source paths" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "bar"
end
- build_lib "bar", "1.0", :path => lib_path("foo/bar")
+ build_lib "bar", "1.0", :path => lib_path("foo")
install_gemfile <<-G
gem "foo", :path => "#{lib_path("foo")}"
@@ -399,7 +433,7 @@ describe "bundle install with explicit source paths" do
end
it "unlocks all gems when a child dependency gem is updated" do
- build_lib "bar", "2.0", :path => lib_path("foo/bar")
+ build_lib "bar", "2.0", :path => lib_path("foo")
bundle "install"
@@ -418,6 +452,7 @@ describe "bundle install with explicit source paths" do
end
it "gets dependencies that are updated in the path" do
+ build_lib "rack", "1.0.0", :path => lib_path("foo")
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack"
end