summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli/gem.rb1
-rw-r--r--lib/bundler/definition.rb19
-rw-r--r--lib/bundler/resolver.rb2
-rw-r--r--lib/bundler/source/rubygems.rb10
-rw-r--r--lib/bundler/source_list.rb30
-rw-r--r--lib/bundler/templates/newgem/sig/newgem.rbs.tt8
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb4
-rw-r--r--lib/rubygems.rb32
-rw-r--r--spec/bundler/commands/newgem_spec.rb7
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb4
-rw-r--r--test/rubygems/test_require.rb10
-rw-r--r--tool/bundler/rubocop_gems.rb.lock11
-rw-r--r--tool/bundler/standard_gems.rb.lock15
-rw-r--r--tool/bundler/test_gems.rb.lock3
14 files changed, 70 insertions, 86 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index e917ceb7d4..31e3af5580 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -76,6 +76,7 @@ module Bundler
"#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
"lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
"lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
+ "sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",
"newgem.gemspec.tt" => "#{name}.gemspec",
"Rakefile.tt" => "Rakefile",
"README.md.tt" => "README.md",
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 97b592da7e..c74bb66c8f 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -163,10 +163,6 @@ module Bundler
end
end
- def multisource_allowed?
- @multisource_allowed
- end
-
def resolve_only_locally!
@remote = false
sources.local_only!
@@ -385,8 +381,8 @@ module Bundler
# Check if it is possible that the source is only changed thing
if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
- new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
- deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
+ new_sources.reject! {|source| source.path? && source.path.exist? }
+ deleted_sources.reject! {|source| source.path? && source.path.exist? }
end
if @locked_sources != gemfile_sources
@@ -718,11 +714,8 @@ module Bundler
deps << dep
end
- s.source = (dep && dep.source) || sources.get(s.source) unless multisource_allowed?
+ s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source unless Bundler.frozen_bundle?
- # Don't add a spec to the list if its source is expired. For example,
- # if you change a Git gem to RubyGems.
- next if s.source.nil?
next if @unlock[:sources].include?(s.source.name)
# If the spec is from a path source and it doesn't exist anymore
@@ -859,12 +852,6 @@ module Bundler
end
end
- def equivalent_rubygems_remotes?(source)
- return false unless source.is_a?(Source::Rubygems)
-
- Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
- end
-
def source_map
@source_map ||= SourceMap.new(sources, dependencies)
end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index d26e2feb10..56002ace60 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -30,10 +30,8 @@ module Bundler
@resolver = Molinillo::Resolver.new(self, self)
@search_for = {}
@base_dg = Molinillo::DependencyGraph.new
- aggregate_global_source = @source_requirements[:default].is_a?(Source::RubygemsAggregate)
@base.each do |ls|
dep = Dependency.new(ls.name, ls.version)
- ls.source = source_for(ls.name) unless aggregate_global_source
@base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
end
additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index b1dd9572c0..2f9d1f5a12 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -262,10 +262,6 @@ module Bundler
@remotes.unshift(uri) unless @remotes.include?(uri)
end
- def equivalent_remotes?(other_remotes)
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
- end
-
def spec_names
if @allow_remote && dependency_api_available?
remote_specs.spec_names
@@ -334,7 +330,11 @@ module Bundler
end
def credless_remotes
- remotes.map(&method(:suppress_configured_credentials))
+ if Bundler.settings[:allow_deployment_source_credential_changes]
+ remotes.map(&method(:remove_auth))
+ else
+ remotes.map(&method(:suppress_configured_credentials))
+ end
end
def remotes_for_spec(spec)
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index d6310b78c0..ba356d40ad 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -98,7 +98,7 @@ module Bundler
end
def get(source)
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
+ source_list_for(source).find {|s| equivalent_source?(source, s) }
end
def lock_sources
@@ -173,7 +173,7 @@ module Bundler
end
def different_sources?(lock_sources, replacement_sources)
- !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
+ !equivalent_sources?(lock_sources, replacement_sources)
end
def rubygems_aggregate_class
@@ -210,34 +210,12 @@ module Bundler
end
end
- def equal_sources?(lock_sources, replacement_sources)
+ def equivalent_sources?(lock_sources, replacement_sources)
lock_sources.sort_by(&:to_s) == replacement_sources.sort_by(&:to_s)
end
- def equal_source?(source, other_source)
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems)
-
- source == other_source
- end
-
def equivalent_source?(source, other_source)
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
-
- equivalent_rubygems_sources?([source], [other_source])
- end
-
- def equivalent_sources?(lock_sources, replacement_sources)
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
-
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
-
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
- end
-
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
+ source == other_source
end
end
end
diff --git a/lib/bundler/templates/newgem/sig/newgem.rbs.tt b/lib/bundler/templates/newgem/sig/newgem.rbs.tt
new file mode 100644
index 0000000000..eb7b380bbb
--- /dev/null
+++ b/lib/bundler/templates/newgem/sig/newgem.rbs.tt
@@ -0,0 +1,8 @@
+<%- config[:constant_array].each_with_index do |c, i| -%>
+<%= " " * i %>module <%= c %>
+<%- end -%>
+<%= " " * config[:constant_array].size %>VERSION: String
+<%= " " * config[:constant_array].size %># See the writing guide of rbs: https://github.com/ruby/rbs#guides
+<%- (config[:constant_array].size-1).downto(0) do |i| -%>
+<%= " " * i %>end
+<%- end -%>
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
index 880170c06b..9d94c2c0f0 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
@@ -32,13 +32,13 @@ class Bundler::ConnectionPool
# rubocop:disable Style/MethodMissingSuper
# rubocop:disable Style/MissingRespondToMissing
- if ::RUBY_VERSION >= "3.0.0"
+ if ::Gem.ruby_version >= ::Gem::Version.new("3.0.0")
def method_missing(name, *args, **kwargs, &block)
with do |connection|
connection.send(name, *args, **kwargs, &block)
end
end
- elsif ::RUBY_VERSION >= "2.7.0"
+ elsif ::Gem.ruby_version >= ::Gem::Version.new("2.7.0")
ruby2_keywords def method_missing(name, *args, &block)
with do |connection|
connection.send(name, *args, &block)
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 37984157de..8e050ef3c7 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1327,22 +1327,6 @@ require_relative 'rubygems/exceptions'
# REFACTOR: This should be pulled out into some kind of hacks file.
begin
##
- # Defaults the operating system (or packager) wants to provide for RubyGems.
-
- require 'rubygems/defaults/operating_system'
-rescue LoadError
- # Ignored
-rescue StandardError => e
- msg = "#{e.message}\n" \
- "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
- "This file is owned by your OS, not by rubygems upstream. " \
- "Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
- "the problem and ask for help."
- raise e.class, msg
-end
-
-begin
- ##
# Defaults the Ruby implementation wants to provide for RubyGems
require "rubygems/defaults/#{RUBY_ENGINE}"
@@ -1356,3 +1340,19 @@ Gem::Specification.load_defaults
require_relative 'rubygems/core_ext/kernel_gem'
require_relative 'rubygems/core_ext/kernel_require'
require_relative 'rubygems/core_ext/kernel_warn'
+
+begin
+ ##
+ # Defaults the operating system (or packager) wants to provide for RubyGems.
+
+ require 'rubygems/defaults/operating_system'
+rescue LoadError
+ # Ignored
+rescue StandardError => e
+ msg = "#{e.message}\n" \
+ "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
+ "This file is owned by your OS, not by rubygems upstream. " \
+ "Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
+ "the problem and ask for help."
+ raise e.class, msg
+end
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 5ba513861c..ddefe0ba25 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -513,6 +513,7 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/Rakefile")).to exist
expect(bundled_app("#{gem_name}/lib/#{require_path}.rb")).to exist
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb")).to exist
+ expect(bundled_app("#{gem_name}/sig/#{require_path}.rbs")).to exist
expect(bundled_app("#{gem_name}/.gitignore")).to exist
expect(bundled_app("#{gem_name}/bin/setup")).to exist
@@ -529,6 +530,12 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb").read).to match(/VERSION = "0.1.0"/)
end
+ it "declare String type for VERSION constant" do
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/sig/#{require_path}.rbs").read).to match(/VERSION: String/)
+ end
+
context "git config user.{name,email} is set" do
before do
bundle "gem #{gem_name}"
diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb
index 9885145662..7a0c148254 100644
--- a/spec/bundler/install/gemfile/sources_spec.rb
+++ b/spec/bundler/install/gemfile/sources_spec.rb
@@ -1250,8 +1250,8 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- it "installs the higher version in the new repo" do
- expect(the_bundle).to include_gems("rack 1.2")
+ it "conservatively installs the existing locked version" do
+ expect(the_bundle).to include_gems("rack 1.0.0")
end
end
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 07e412cc76..4d0301742e 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -466,8 +466,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_default_gem
- testing_ruby_repo = !ENV["GEM_COMMAND"].nil?
- pend "this test can't work under ruby-core setup" if testing_ruby_repo || java_platform?
+ omit "this test can't work under ruby-core setup" if testing_ruby_repo?
cmd = <<-RUBY
$stderr = $stdout
@@ -480,8 +479,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_upgraded_default_gem
- testing_ruby_repo = !ENV["GEM_COMMAND"].nil?
- pend "this test can't work under ruby-core setup" if testing_ruby_repo
+ omit "this test can't work under ruby-core setup" if testing_ruby_repo?
newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"])
install_gem newer_json
@@ -720,6 +718,10 @@ class TestGemRequire < Gem::TestCase
private
+ def testing_ruby_repo?
+ !ENV["GEM_COMMAND"].nil?
+ end
+
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, false
yield
diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock
index a4d2446902..8d1e9c759c 100644
--- a/tool/bundler/rubocop_gems.rb.lock
+++ b/tool/bundler/rubocop_gems.rb.lock
@@ -26,20 +26,20 @@ GEM
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
- rspec-support (3.10.2)
- rubocop (1.21.0)
+ rspec-support (3.10.3)
+ rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
- rubocop-ast (>= 1.9.1, < 2.0)
+ rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.11.0)
+ rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
- test-unit (3.4.7)
+ test-unit (3.5.1)
power_assert
unicode-display_width (2.1.0)
@@ -47,6 +47,7 @@ PLATFORMS
arm64-darwin-20
universal-java-11
x86_64-darwin-19
+ x86_64-darwin-20
x86_64-linux
DEPENDENCIES
diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock
index 326d88b5a7..68186165c3 100644
--- a/tool/bundler/standard_gems.rb.lock
+++ b/tool/bundler/standard_gems.rb.lock
@@ -26,26 +26,26 @@ GEM
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
- rspec-support (3.10.2)
- rubocop (1.20.0)
+ rspec-support (3.10.3)
+ rubocop (1.22.3)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
- rubocop-ast (>= 1.9.1, < 2.0)
+ rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
- rubocop-ast (1.11.0)
+ rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-performance (1.11.5)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.11.0)
- standard (1.3.0)
- rubocop (= 1.20.0)
+ standard (1.4.0)
+ rubocop (= 1.22.3)
rubocop-performance (= 1.11.5)
- test-unit (3.4.7)
+ test-unit (3.5.1)
power_assert
unicode-display_width (2.1.0)
@@ -53,6 +53,7 @@ PLATFORMS
arm64-darwin-20
universal-java-11
x86_64-darwin-19
+ x86_64-darwin-20
x86_64-linux
DEPENDENCIES
diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock
index f8fa01b59c..2f1dab91e2 100644
--- a/tool/bundler/test_gems.rb.lock
+++ b/tool/bundler/test_gems.rb.lock
@@ -13,7 +13,7 @@ GEM
rack-test (1.1.0)
rack (>= 1.0, < 3)
rake (13.0.1)
- ruby2_keywords (0.0.2)
+ ruby2_keywords (0.0.5)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -27,6 +27,7 @@ PLATFORMS
ruby
universal-java-11
x64-mingw32
+ x86_64-darwin-20
x86_64-linux
DEPENDENCIES