diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 564552a3b80..ad05dd6217d 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -293,6 +293,13 @@ def pretty_dep(dep, source = false) end def converge_sources + locked_gem = @locked_sources.find { |s| Source::Rubygems === s } + actual_gem = @sources.find { |s| Source::Rubygems === s } + + if locked_gem && actual_gem + locked_gem.merge_remotes actual_gem + end + @sources.map! do |source| @locked_sources.find { |s| s == source } || source end diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 75a26a84aec..31555893f36 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -129,6 +129,13 @@ def add_remote(source) @remotes << normalize_uri(source) end + def merge_remotes(source) + @remotes = [] + source.remotes.each do |r| + add_remote r.to_s + end + end + private def cached_gem(spec) diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb index 8a5c1a3dbed..e8520715814 100644 --- a/spec/install/gems/flex_spec.rb +++ b/spec/install/gems/flex_spec.rb @@ -220,7 +220,7 @@ G gemfile <<-G - source "file:://#{gem_repo1}" + source "file://#{gem_repo1}" gem "rack", "0.9.1" gem "rack-obama" G @@ -240,4 +240,33 @@ bundle "update rack" end end + + describe "when adding a new source" do + it "updates the lockfile" do + build_repo2 + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + install_gemfile <<-G + source "file://#{gem_repo1}" + source "file://#{gem_repo2}" + gem "rack" + G + + lockfile_should_be <<-L + GEM + remote: file:#{gem_repo1}/ + remote: file:#{gem_repo2}/ + specs: + rack (1.0.0) + + PLATFORMS + ruby + + DEPENDENCIES + rack + L + end + end end