diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli/gem.rb | 1 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 19 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 2 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 10 | ||||
-rw-r--r-- | lib/bundler/source_list.rb | 30 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/sig/newgem.rbs.tt | 8 | ||||
-rw-r--r-- | lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb | 4 | ||||
-rw-r--r-- | lib/rubygems.rb | 32 |
8 files changed, 39 insertions, 67 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 |