summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-06-22 21:48:35 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-27 16:27:22 -0500
commit435655a98d75a9b0c82a92809b701c65fe6498a8 (patch)
tree3b0063da7129ff59f41c19b7731689a244884782
parentbd8982c525bd79302d4551e1ad0053722de4b0b6 (diff)
downloadbundler-435655a98d75a9b0c82a92809b701c65fe6498a8.tar.gz
Remove the notion of a rubygems aggregate
-rw-r--r--lib/bundler/definition.rb21
-rw-r--r--lib/bundler/dsl.rb6
-rw-r--r--lib/bundler/source/rubygems.rb4
-rw-r--r--lib/bundler/source_list.rb25
-rw-r--r--spec/install/gemfile/sources_spec.rb2
-rw-r--r--spec/lock/lockfile_spec.rb62
6 files changed, 40 insertions, 80 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 275f4ee8ac..1d890e73ee 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -203,7 +203,7 @@ module Bundler
last_resolve
else
# Run a resolve against the locally available gems
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version)
+ last_resolve.merge Resolver.resolve(expanded_dependencies, global_rubygems_index, source_requirements, last_resolve, ruby_version)
end
end
end
@@ -221,6 +221,12 @@ module Bundler
end
end
+ def global_rubygems_index
+ @global_rubygems_index ||= Index.build do |idx|
+ idx.add_source(sources.rubygems_global.specs) if sources.rubygems_global
+ end
+ end
+
# used when frozen is enabled so we can find the bundler
# spec, even if (say) a git gem is not checked out.
def rubygems_index
@@ -496,19 +502,6 @@ module Bundler
def converge_sources
changes = false
- # Get the Rubygems sources from the gems.locked
- locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
- # Get the Rubygems remotes from the gems.rb
- actual_remotes = sources.rubygems_remotes
-
- # If there is a Rubygems source in both
- if !locked_gem_sources.empty? && !actual_remotes.empty?
- locked_gem_sources.each do |locked_gem|
- # Merge the remotes from the gems.rb into the gems.locked
- changes |= locked_gem.replace_remotes(actual_remotes)
- end
- end
-
# Replace the sources from the gems.rb with the sources from the gems.locked,
# if they exist in the gems.locked and are `==`. If you can't find an equivalent
# source in the gems.locked, use the one from the gems.rb.
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index aaa0eab06d..6b8f7ca66a 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -132,7 +132,7 @@ module Bundler
with_source(@sources.add_rubygems_source("remotes" => source), &blk)
else
check_primary_source_safety(@sources)
- @sources.add_rubygems_remote(source)
+ @sources.set_global_rubygems_remote(source)
end
end
@@ -384,8 +384,8 @@ module Bundler
end
end
- def check_primary_source_safety(source)
- return unless source.rubygems_primary_remotes.any?
+ def check_primary_source_safety(source_list)
+ return if source_list.rubygems_global.nil?
raise GemspecError, "This #{SharedHelpers.gemfile_name} contains multiple primary sources. " \
"Each source after the first must include a block to indicate which gems " \
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 6b09173130..5eb42c9010 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -48,10 +48,6 @@ module Bundler
o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
end
- def can_lock?(spec)
- spec.source.is_a?(Rubygems)
- end
-
def options
{ "remotes" => @remotes.map(&:to_s) }
end
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index d1c3c8c170..843f823a75 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -4,12 +4,13 @@ require "set"
module Bundler
class SourceList
attr_reader :path_sources,
- :git_sources
+ :git_sources,
+ :rubygems_global
def initialize
@path_sources = []
@git_sources = []
- @rubygems_aggregate = Source::Rubygems.new
+ @rubygems_global = nil
@rubygems_sources = []
end
@@ -27,13 +28,12 @@ module Bundler
add_source_to_list Source::Rubygems.new(options), @rubygems_sources
end
- def add_rubygems_remote(uri)
- @rubygems_aggregate.add_remote(uri)
- @rubygems_aggregate
+ def set_global_rubygems_remote(uri)
+ @rubygems_global = Source::Rubygems.new("remotes" => uri)
end
def rubygems_sources
- @rubygems_sources + [@rubygems_aggregate]
+ @rubygems_sources + [@rubygems_global].compact
end
def rubygems_remotes
@@ -44,13 +44,12 @@ module Bundler
path_sources + git_sources + rubygems_sources
end
- def get(source)
- source_list_for(source).find {|s| source == s }
+ def lock_sources
+ all_sources.sort_by(&:to_lock)
end
- def lock_sources
- lock_sources = (path_sources + git_sources).sort_by(&:to_s)
- lock_sources << combine_rubygems_sources
+ def get(source)
+ source_list_for(source).find {|s| source == s }
end
def replace_sources!(replacement_sources)
@@ -79,10 +78,6 @@ module Bundler
all_sources.each(&:remote!)
end
- def rubygems_primary_remotes
- @rubygems_aggregate.remotes
- end
-
private
def add_source_to_list(source, list)
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 206dfa44be..889e6b5e12 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -30,7 +30,7 @@ describe "bundle install with gems on multiple sources" do
it "errors when disable_multisource is set" do
bundle "config disable_multisource true"
- bundle :install
+ bundle :install, :expect_err => true
expect(err).to include("Each source after the first must include a block")
expect(exitstatus).to eq(14) if exitstatus
end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index e6b4ba34d1..844f634cbc 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -359,18 +359,21 @@ describe "the lockfile format" do
G
end
- it "generates a lockfile wihout credentials for a configured source" do
+ it "generates a lockfile without credentials for a configured source" do
bundle "config http://localgemserver.test/ user:pass"
install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://localgemserver.test/"
+ source "http://user:pass@othergemserver.test/"
gem "rack-obama", ">= 1.0"
- source "http://user:pass@othergemserver.test/" do; end
+ source "http://localgemserver.test/" do; end
G
lockfile_should_be <<-G
GEM
remote: http://localgemserver.test/
+ specs:
+
+ GEM
remote: http://user:pass@othergemserver.test/
specs:
rack (1.0.0)
@@ -429,9 +432,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -498,9 +498,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -528,9 +525,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -558,9 +552,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -585,9 +576,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -612,6 +600,11 @@ describe "the lockfile format" do
G
lockfile_should_be <<-G
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
GIT
remote: #{lib_path("bar-1.0")}
revision: #{bar.ref_for("master")}
@@ -623,11 +616,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- remote: file:#{gem_repo1}/
- specs:
- rack (1.0.0)
-
PLATFORMS
#{generic_local_platform}
@@ -807,9 +795,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -835,9 +820,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -863,9 +845,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -890,9 +869,6 @@ describe "the lockfile format" do
specs:
foo (1.0)
- GEM
- specs:
-
PLATFORMS
#{generic_local_platform}
@@ -1172,6 +1148,10 @@ describe "the lockfile format" do
# Create a gems.locked that has duplicate GIT sections
lockfile <<-L
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1186,10 +1166,6 @@ describe "the lockfile format" do
specs:
omg (1.0)
- GEM
- remote: file:#{gem_repo1}/
- specs:
-
PLATFORMS
#{local}
@@ -1206,6 +1182,10 @@ describe "the lockfile format" do
# Confirm that duplicate specs do not appear
expect(File.read(bundled_app("gems.locked"))).to eq(strip_whitespace(<<-L))
+ GEM
+ remote: file:#{gem_repo1}/
+ specs:
+
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1213,10 +1193,6 @@ describe "the lockfile format" do
specs:
omg (1.0)
- GEM
- remote: file:#{gem_repo1}/
- specs:
-
PLATFORMS
#{local}