diff options
-rw-r--r-- | lib/bundler/definition.rb | 4 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 9 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 10 | ||||
-rw-r--r-- | lib/bundler/source_list.rb | 10 | ||||
-rw-r--r-- | spec/bundler/source_list_spec.rb | 13 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 80 |
6 files changed, 82 insertions, 44 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index eb97b81a5d..ac5a17f0d9 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -338,8 +338,8 @@ module Bundler gemfile_sources = sources.lock_sources if @locked_sources != gemfile_sources - new_sources = gemfile_sources - @locked_sources - deleted_sources = @locked_sources - gemfile_sources + new_sources = gemfile_sources - @locked_sources - [sources.rubygems_aggregate] + deleted_sources = @locked_sources - gemfile_sources - [sources.rubygems_aggregate] if new_sources.any? added.concat new_sources.map { |source| "* source: #{source}" } diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 21367fe70c..cf9696917a 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -101,10 +101,13 @@ module Bundler @sources << @current_source end when GEM - Array(@opts["remote"]).each do |url| - @rubygems_aggregate.add_remote(url) + @current_source = TYPES[@type].from_lock(@opts) + # Strip out duplicate rubygems sections + if @sources.include?(@current_source) + @current_source = @sources.find { |s| s == @current_source } + else + @sources << @current_source end - @current_source = @rubygems_aggregate end when OPTIONS value = $2 diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 797988f365..4643958cad 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -43,12 +43,10 @@ module Bundler alias == eql? - def include?(o) - o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty? - end - def can_lock?(spec) - spec.source.is_a?(Rubygems) + return false unless spec.source.is_a?(Rubygems) + + !(spec.source.credless_remotes - credless_remotes).empty? end def options @@ -229,6 +227,8 @@ module Bundler end end + private + def loaded_from(spec) "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec" end diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index 546b3b14be..dfb993b771 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -1,7 +1,8 @@ module Bundler class SourceList attr_reader :path_sources, - :git_sources + :git_sources, + :rubygems_aggregate def initialize @path_sources = [] @@ -46,8 +47,7 @@ module Bundler end def lock_sources - lock_sources = (path_sources + git_sources).sort_by(&:to_s) - lock_sources << combine_rubygems_sources + all_sources.sort_by(&:to_s) end def replace_sources!(replacement_sources) @@ -96,10 +96,6 @@ module Bundler end end - def combine_rubygems_sources - Source::Rubygems.new("remotes" => rubygems_remotes) - end - def warn_on_git_protocol(source) return if Bundler.settings["git.allow_insecure"] diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb index 25e0e54391..be52e30e9c 100644 --- a/spec/bundler/source_list_spec.rb +++ b/spec/bundler/source_list_spec.rb @@ -283,7 +283,7 @@ describe Bundler::SourceList do end describe "#lock_sources" do - it "combines the rubygems sources into a single instance, removing duplicate remotes from the end" do + it "returns each rubygems source" do source_list.add_git_source('uri' => 'git://third-git.org/path.git') source_list.add_rubygems_source('remotes' => ['https://duplicate-rubygems.org']) source_list.add_path_source('path' => '/third/path/to/gem') @@ -300,15 +300,14 @@ describe Bundler::SourceList do Bundler::Source::Git.new('uri' => 'git://first-git.org/path.git'), Bundler::Source::Git.new('uri' => 'git://second-git.org/path.git'), Bundler::Source::Git.new('uri' => 'git://third-git.org/path.git'), + Bundler::Source::Rubygems.new, + Bundler::Source::Rubygems.new('remotes' => ['https://duplicate-rubygems.org']), + Bundler::Source::Rubygems.new('remotes' => ['https://first-rubygems.org']), + Bundler::Source::Rubygems.new('remotes' => ['https://second-rubygems.org']), + Bundler::Source::Rubygems.new('remotes' => ['https://third-rubygems.org']), Bundler::Source::Path.new('path' => '/first/path/to/gem'), Bundler::Source::Path.new('path' => '/second/path/to/gem'), Bundler::Source::Path.new('path' => '/third/path/to/gem'), - Bundler::Source::Rubygems.new('remotes' => [ - 'https://duplicate-rubygems.org', - 'https://first-rubygems.org', - 'https://second-rubygems.org', - 'https://third-rubygems.org', - ]), ] end end diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 74a1f82581..c72dbc577d 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -544,14 +544,14 @@ describe "the lockfile format" do G lockfile_should_be <<-G + GEM + specs: + PATH remote: #{lib_path("foo-1.0")} specs: foo (1.0) - GEM - specs: - PLATFORMS #{generic(Gem::Platform.local)} @@ -582,16 +582,16 @@ describe "the lockfile format" do specs: bar (1.0) - PATH - remote: #{lib_path("foo-1.0")} - specs: - foo (1.0) - GEM remote: file:#{gem_repo1}/ specs: rack (1.0.0) + PATH + remote: #{lib_path("foo-1.0")} + specs: + foo (1.0) + PLATFORMS #{generic(Gem::Platform.local)} @@ -766,14 +766,14 @@ describe "the lockfile format" do G lockfile_should_be <<-G + GEM + specs: + PATH remote: foo specs: foo (1.0) - GEM - specs: - PLATFORMS #{generic(Gem::Platform.local)} @@ -794,14 +794,14 @@ describe "the lockfile format" do G lockfile_should_be <<-G + GEM + specs: + PATH remote: ../foo specs: foo (1.0) - GEM - specs: - PLATFORMS #{generic(Gem::Platform.local)} @@ -822,14 +822,14 @@ describe "the lockfile format" do G lockfile_should_be <<-G + GEM + specs: + PATH remote: foo specs: foo (1.0) - GEM - specs: - PLATFORMS #{generic(Gem::Platform.local)} @@ -849,14 +849,14 @@ describe "the lockfile format" do G lockfile_should_be <<-G + GEM + specs: + PATH remote: ../foo specs: foo (1.0) - GEM - specs: - PLATFORMS #{generic(Gem::Platform.local)} @@ -1264,4 +1264,44 @@ describe "the lockfile format" do expect(err).to match(/your Gemfile.lock contains merge conflicts/i) expect(err).to match(/git checkout HEAD -- Gemfile.lock/i) end + + it "stores each rubygems source in its own source section" do + build_repo gem_repo3 do + build_gem "cocoapods", "0.37.0" + end + + install_gemfile <<-G + source "file://#{gem_repo3}" + source "file://#{gem_repo1}" do + gem "thin" # comes first to test name sorting + gem "rack" + end + gem "cocoapods" # shoud come from repo3! + G + + lockfile_should_be <<-L + GEM + remote: file:/Users/segiddins/Development/OpenSource/bundler/tmp/gems/remote1/ + specs: + rack (1.0.0) + thin (1.0) + rack + + GEM + remote: file:/Users/segiddins/Development/OpenSource/bundler/tmp/gems/remote3/ + specs: + cocoapods (0.37.0) + + PLATFORMS + ruby + + DEPENDENCIES + cocoapods + rack! + thin! + + BUNDLED WITH + #{Bundler::VERSION} + L + end end |