1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge rubygems master fd676ac464491afaa0baf5435cb11b3f86229cbd

This commit is contained in:
Hiroshi SHIBATA 2021-12-01 11:00:10 +09:00
parent 9f4bdeb403
commit 0b53a8895f
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
14 changed files with 70 additions and 86 deletions

View file

@ -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",

View file

@ -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

View file

@ -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) }

View file

@ -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)

View file

@ -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

View file

@ -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 -%>

View file

@ -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)

View file

@ -1325,22 +1325,6 @@ end
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
@ -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

View file

@ -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}"

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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