diff options
author | Andre Arko <andre@arko.net> | 2013-08-18 22:44:11 -0700 |
---|---|---|
committer | Tim Moore <tmoore@incrementalism.net> | 2014-07-30 14:16:36 +1000 |
commit | 53c296d2cf1823d3f9ff84af50b84a38938cd4a3 (patch) | |
tree | 04e92502369ed060644581ec3b8f0070179888ec /lib | |
parent | a0e2c8dcbf94f0e8d52230e89f9be11f8c228c7d (diff) | |
download | bundler-53c296d2cf1823d3f9ff84af50b84a38938cd4a3.tar.gz |
lockfile source parity
the lockfile parser was creating and then providing a single rubygems
source, with multiple remotes. that doesn't work now that we have
multiple remotes, so I updated it to create source objects for all
of the remotes that are in the lockfile.
this doesn't solve the problem of source affinity at all, and at best
just punts on it, but we definitely need the lockfile parser to return
multiple rubygems sources instead of just one.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 27 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 8 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 01fa86321a..32eb43a4dc 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -29,6 +29,8 @@ module Bundler @state = :source @specs = {} + @rubygems_aggregate = Source::Rubygems.new + if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/) raise LockfileError, "Your Gemfile.lock contains merge conflicts.\n" \ "Run `git checkout HEAD -- Gemfile.lock` first to get a clean lock." @@ -43,6 +45,7 @@ module Bundler send("parse_#{@state}", line) end end + @sources << @rubygems_aggregate @specs = @specs.values end @@ -60,14 +63,24 @@ module Bundler @current_source = nil @opts, @type = {}, line when SPECS - @current_source = TYPES[@type].from_lock(@opts) - - # Strip out duplicate GIT sections - if @sources.include?(@current_source) && @current_source.is_a?(Bundler::Source::Git) - @current_source = @sources.find { |s| s == @current_source } + case @type + when "PATH" + @current_source = TYPES[@type].from_lock(@opts) + @sources << @current_source + when "GIT" + @current_source = TYPES[@type].from_lock(@opts) + # Strip out duplicate GIT sections + if @type == "GIT" && @sources.include?(@current_source) + @current_source = @sources.find { |s| s == @current_source } + else + @sources << @current_source + end + when "GEM" + Array(@opts["remote"]).each do |url| + @rubygems_aggregate.add_remote(url) + end + @current_source = @rubygems_aggregate end - - @sources << @current_source when OPTIONS value = $2 value = true if value == "true" diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index eb60a50808..178c186eef 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -12,12 +12,14 @@ module Bundler def initialize(options = {}) @options = options - @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) } + @remotes = [] @fetchers = {} @dependency_names = [] @allow_remote = false @allow_cached = false @caches = [Bundler.app_cache, *Bundler.rubygems.gem_cache] + + Array(options["remotes"] || []).reverse_each{|r| add_remote(r) } end def remote! @@ -47,9 +49,7 @@ module Bundler end def self.from_lock(options) - s = new(options) - Array(options["remote"]).each { |r| s.add_remote(r) } - s + new(options) end def to_lock |