ruby-changes:65447
From: Hiroshi <ko1@a...>
Date: Thu, 11 Mar 2021 17:25:14 +0900 (JST)
Subject: [ruby-changes:65447] 7efc7afcae (ruby_3_0): Merge RubyGems-3.2.13 and Bundler-2.2.13
https://git.ruby-lang.org/ruby.git/commit/?id=7efc7afcae From 7efc7afcae6720e1af7ab49986d789b6f9d6fe0a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Mon, 8 Mar 2021 12:17:52 +0900 Subject: Merge RubyGems-3.2.13 and Bundler-2.2.13 --- lib/bundler/cli/gem.rb | 40 ++++--- lib/bundler/definition.rb | 47 ++++---- lib/bundler/dsl.rb | 58 ++++++---- lib/bundler/inline.rb | 1 + lib/bundler/lockfile_parser.rb | 20 ++-- lib/bundler/plugin.rb | 1 + lib/bundler/plugin/installer.rb | 18 ++- lib/bundler/plugin/source_list.rb | 4 + lib/bundler/resolver.rb | 70 ++++++------ lib/bundler/source_list.rb | 33 +++--- lib/bundler/templates/newgem/README.md.tt | 8 +- lib/bundler/version.rb | 2 +- lib/rubygems.rb | 2 +- lib/rubygems/core_ext/tcpsocket_init.rb | 5 +- lib/rubygems/platform.rb | 10 +- spec/bundler/bundler/plugin_spec.rb | 1 + spec/bundler/commands/exec_spec.rb | 131 +++++++++++++++++---- spec/bundler/commands/newgem_spec.rb | 94 ++++++--------- spec/bundler/commands/post_bundle_message_spec.rb | 11 +- spec/bundler/install/gemfile/gemspec_spec.rb | 15 ++- spec/bundler/install/gemfile/sources_spec.rb | 132 +++++++++++++++++++--- spec/bundler/support/indexes.rb | 2 +- test/rubygems/test_gem.rb | 10 +- test/rubygems/test_gem_platform.rb | 29 +++++ 24 files changed, 477 insertions(+), 267 deletions(-) diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 0d77357..2c63da9 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -39,11 +39,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L39 constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase } constant_array = constant_name.split("::") - git_installed = Bundler.git_present? + use_git = Bundler.git_present? && options[:git] - git_author_name = git_installed ? `git config user.name`.chomp : "" - github_username = git_installed ? `git config github.user`.chomp : "" - git_user_email = git_installed ? `git config user.email`.chomp : "" + git_author_name = use_git ? `git config user.name`.chomp : "" + github_username = use_git ? `git config github.user`.chomp : "" + git_user_email = use_git ? `git config user.email`.chomp : "" config = { :name => name, @@ -58,6 +58,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L58 :ext => options[:ext], :exe => options[:exe], :bundler_version => bundler_dependency_version, + :git => use_git, :github_username => github_username.empty? ? "[USERNAME]" : github_username, :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0", } @@ -79,7 +80,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L80 bin/setup ] - templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present? + templates.merge!("gitignore.tt" => ".gitignore") if use_git if test_framework = ask_and_set_test_framework config[:test] = test_framework @@ -175,24 +176,31 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L176 ) end + if File.exist?(target) && !File.directory?(target) + Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`." + exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError] + end + + if use_git + Bundler.ui.info "Initializing git repo in #{target}" + `git init #{target}` + + config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp + end + templates.each do |src, dst| destination = target.join(dst) - SharedHelpers.filesystem_access(destination) do - thor.template("newgem/#{src}", destination, config) - end + thor.template("newgem/#{src}", destination, config) end executables.each do |file| - SharedHelpers.filesystem_access(target.join(file)) do |path| - executable = (path.stat.mode | 0o111) - path.chmod(executable) - end + path = target.join(file) + executable = (path.stat.mode | 0o111) + path.chmod(executable) end - if Bundler.git_present? && options[:git] - Bundler.ui.info "Initializing git repo in #{target}" + if use_git Dir.chdir(target) do - `git init` `git add .` end end @@ -202,8 +210,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/gem.rb#L210 Bundler.ui.info "Gem '#{name}' was successfully created. " \ "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html" - rescue Errno::EEXIST => e - raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.") end private diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 3264cb0..a09d661 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -264,7 +264,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L264 # Run a resolve against the locally available gems Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}") expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote) - Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) + Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) end end end @@ -656,19 +656,20 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L656 def converge_rubygems_sources return false if Bundler.feature_flag.disable_multisource? - changes = false - # Get the RubyGems sources from the Gemfile.lock locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) } + return false if locked_gem_sources.empty? + # Get the RubyGems remotes from the Gemfile actual_remotes = sources.rubygems_remotes + return false if actual_remotes.empty? + + changes = false # 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 Gemfile into the Gemfile.lock - changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes]) - end + locked_gem_sources.each do |locked_gem| + # Merge the remotes from the Gemfile into the Gemfile.lock + changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes]) end changes @@ -893,30 +894,18 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L894 # Record the specs available in each gem's source, so that those # specs will be available later when the resolver knows where to # look for that gemspec (or its dependencies) - default = sources.default_source - source_requirements = { :default => default } - default = nil unless Bundler.feature_flag.disable_multisource? - dependencies.each do |dep| - next unless source = dep.source || default - source_requirements[dep.name] = source - end + source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements) metadata_dependencies.each do |dep| source_requirements[dep.name] = sources.metadata_source end + source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource? source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default] source_requirements["bundler"] = sources.metadata_source # needs to come last to override source_requirements end def pinned_spec_names(skip = nil) - pinned_names = [] - default = Bundler.feature_flag.disable_multisource? && sources.default_source - @dependencies.each do |dep| - next unless dep_source = dep.source || default - next if dep_source == skip - pinned_names << dep.name - end - pinned_names + dependency_source_requirements.reject {|_, source| source == skip }.keys end def requested_groups @@ -973,5 +962,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L962 Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes) end + + def dependency_source_requirements + @dependency_source_requirements ||= begin + source_requirements = {} + default = sources.default_source + dependencies.each do |dep| + dep_source = dep.source || default + source_requirements[dep.name] = dep_source + end + source_requirements + end + end end end diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb in (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/