diff options
author | Andre Arko <andre@arko.net> | 2015-02-07 09:46:33 +1100 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-02-08 11:21:25 +1100 |
commit | b8594666c185a2e431487795d24a31b88846e955 (patch) | |
tree | 5bf498abd5346ee8cefa0f10ae41f9dbce57c9ae | |
parent | 0dfceb1164361aeaa394de44289dfcb983779081 (diff) | |
download | bundler-b8594666c185a2e431487795d24a31b88846e955.tar.gz |
only remove dependency names for local sources
If a gem is present in a git or path source, we can stop asking remotes
about it. If a gem is present in a Rubygems source, we still need to ask
all the other sources about it so that we can warn about gems that are
available from multiple sources.
Fixes #3368, #3377, #3300, #3381
-rw-r--r-- | lib/bundler/definition.rb | 6 | ||||
-rw-r--r-- | spec/install/gems/dependency_api_spec.rb | 27 | ||||
-rw-r--r-- | spec/support/builders.rb | 4 |
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 0d51770ac3..1c05f2aeed 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -202,7 +202,11 @@ module Bundler sources.all_sources.each do |s| s.dependency_names = dependency_names.dup idx.add_source s.specs - dependency_names -= s.specs.map{|s| s.name }.uniq + + if s.is_a?(Source::Git) || s.is_a?(Source::Path) + dependency_names -= s.specs.map{|s| s.name }.uniq + end + dependency_names.push(*s.unmet_deps).uniq! end end diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index a29efe87cf..bccc5a8a11 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -259,6 +259,31 @@ describe "gemcutter's dependency API" do should_be_installed "back_deps 1.0" end + it "fetches gem versions even when those gems are already installed" do + build_repo4 + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do; end + gem "rack", "1.0.0" + G + bundle :install, :artifice => "endpoint_extra_api" + + update_repo gem_repo1 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + end + + gemfile <<-G + source "#{source_uri}" + source "#{source_uri}/extra" do; end + gem "rack", "1.2" + G + bundle :install, :artifice => "endpoint_extra_api" + should_be_installed "rack 1.2" + end + it "considers all possible versions of dependencies from all api gem sources" do # In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that # exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0 @@ -303,7 +328,7 @@ describe "gemcutter's dependency API" do expect(out).to include("Fetching source index from http://localgemserver.test/extra") end - it "does not fetch every specs if the index of gems is large when doing back deps" do + it "does not fetch every spec if the index of gems is large when doing back deps" do build_repo2 do build_gem "back_deps" do |s| s.add_dependency "foo" diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 7e2bb74003..dadaa731ce 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -263,7 +263,9 @@ module Spec # A repo that has no pre-installed gems included. (The caller completely determines the contents with the block) def build_repo4(&blk) FileUtils.rm_rf gem_repo4 - build_repo(gem_repo4, &blk) + build_repo(gem_repo4) do + yield if block_given? + end end def update_repo2 |