aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2022-12-26 14:00:11 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2022-12-26 15:09:21 +0900
commitb7ad60a79440f65cf883d3ff9dbdde701666ef56 (patch)
treee0033b706a480377472bf93f58eaf42f6e2301ab
parent10c9ce9d4c632d7c6232b53367b0496aef2ebb13 (diff)
downloadruby-b7ad60a79440f65cf883d3ff9dbdde701666ef56.tar.gz
Merge RubyGems/Bundler master
from https://github.com/rubygems/rubygems/commit/72fd3dd2096af16d797ad0cd8e0d2a8869e240b3
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/cli/binstubs.rb2
-rw-r--r--lib/bundler/cli/info.rb2
-rw-r--r--lib/bundler/cli/install.rb2
-rw-r--r--lib/bundler/cli/outdated.rb2
-rw-r--r--lib/bundler/cli/platform.rb12
-rw-r--r--lib/bundler/definition.rb6
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/env.rb2
-rw-r--r--lib/bundler/fetcher/compact_index.rb4
-rw-r--r--lib/bundler/friendly_errors.rb2
-rw-r--r--lib/bundler/gem_helper.rb7
-rw-r--r--lib/bundler/installer/parallel_installer.rb2
-rw-r--r--lib/bundler/plugin/index.rb2
-rw-r--r--lib/bundler/ruby_version.rb4
-rw-r--r--lib/bundler/rubygems_integration.rb2
-rw-r--r--lib/bundler/ui/rg_proxy.rb2
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb5
-rw-r--r--lib/rubygems/bundler_version_finder.rb2
-rw-r--r--lib/rubygems/gemcutter_utilities.rb3
-rw-r--r--lib/rubygems/package.rb3
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb2
-rw-r--r--lib/rubygems/specification.rb4
-rw-r--r--lib/rubygems/user_interaction.rb4
-rw-r--r--spec/bundler/realworld/fixtures/warbler/Gemfile.lock2
-rw-r--r--spec/bundler/support/artifice/vcr.rb2
-rw-r--r--test/rubygems/helper.rb2
-rw-r--r--tool/bundler/dev_gems.rb.lock2
-rw-r--r--tool/bundler/rubocop_gems.rb.lock2
-rw-r--r--tool/bundler/standard_gems.rb.lock2
-rw-r--r--tool/bundler/test_gems.rb.lock2
32 files changed, 47 insertions, 49 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index c6a225977f..84ef033fe3 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -537,7 +537,7 @@ EOF
@gemspec_cache[key] ||= load_gemspec_uncached(file, validate)
# Protect against caching side-effected gemspecs by returning a
# new instance each time.
- @gemspec_cache[key].dup if @gemspec_cache[key]
+ @gemspec_cache[key]&.dup
end
def load_gemspec_uncached(file, validate = false)
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index 639c01ff39..09541b1955 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -11,7 +11,7 @@ module Bundler
def run
Bundler.definition.validate_runtime!
path_option = options["path"]
- path_option = nil if path_option && path_option.empty?
+ path_option = nil if path_option&.empty?
Bundler.settings.set_command_option :bin, path_option if options["path"]
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
installer = Installer.new(Bundler.root, Bundler.definition)
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index 0545ce8c75..36c7a58f12 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -33,7 +33,7 @@ module Bundler
def default_gem_spec(gem_name)
return unless Gem::Specification.respond_to?(:find_all_by_name)
gem_spec = Gem::Specification.find_all_by_name(gem_name).last
- return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem?
+ return gem_spec if gem_spec&.default_gem?
end
def spec_not_found(gem_name)
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 1765621cb3..c71bcf159f 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -154,7 +154,7 @@ module Bundler
end
bin_option = options["binstubs"]
- bin_option = nil if bin_option && bin_option.empty?
+ bin_option = nil if bin_option&.empty?
Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 12c3384938..68c701aefb 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -194,7 +194,7 @@ module Bundler
end
current_version = "#{current_spec.version}#{current_spec.git_version}"
- if dependency && dependency.specific?
+ if dependency&.specific?
dependency_version = %(, requested #{dependency.requirement})
end
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb
index 73da8cf80e..32d68abbb1 100644
--- a/lib/bundler/cli/platform.rb
+++ b/lib/bundler/cli/platform.rb
@@ -8,12 +8,12 @@ module Bundler
end
def run
- platforms, ruby_version = Bundler.ui.silence do
- locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
- gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
- [Bundler.definition.platforms.map {|p| "* #{p}" },
- locked_ruby_version || gemfile_ruby_version]
+ ruby_version = if Bundler.locked_gems
+ Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
+ else
+ Bundler.definition.ruby_version&.single_version_string
end
+
output = []
if options[:ruby]
@@ -23,6 +23,8 @@ module Bundler
output << "No ruby version specified"
end
else
+ platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
+
output << "Your platform is: #{Gem::Platform.local}"
output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 348f1b6a3d..2f652cb5a7 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -647,8 +647,8 @@ module Bundler
Bundler.settings.local_overrides.map do |k, v|
spec = @dependencies.find {|s| s.name == k }
- source = spec && spec.source
- if source && source.respond_to?(:local_override!)
+ source = spec&.source
+ if source&.respond_to?(:local_override!)
source.unlock! if @unlock[:gems].include?(spec.name)
locals << [source, source.local_override!(v)]
end
@@ -778,7 +778,7 @@ module Bundler
dep = @dependencies.find {|d| s.satisfies?(d) }
# Replace the locked dependency's source with the equivalent source from the Gemfile
- s.source = if dep && dep.source
+ s.source = if dep&.source
gemfile_source = dep.source
lockfile_source = s.source
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 179fea4dfd..0492f52cfc 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -41,7 +41,7 @@ module Bundler
end
def eval_gemfile(gemfile, contents = nil)
- expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile && @gemfile.parent)
+ expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
original_gemfile = @gemfile
@gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 8b2e292fd6..7b1152930e 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -122,7 +122,7 @@ module Bundler
specs = Bundler.rubygems.find_name(name)
out << [" #{name}", "(#{specs.map(&:version).join(",")})"] unless specs.empty?
end
- if (exe = caller.last.split(":").first) && exe =~ %r{(exe|bin)/bundler?\z}
+ if (exe = caller.last.split(":").first)&.match? %r{(exe|bin)/bundler?\z}
shebang = File.read(exe).lines.first
shebang.sub!(/^#!\s*/, "")
unless shebang.start_with?(Gem.ruby, "/usr/bin/env ruby")
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 77838f0361..674d2b49f1 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -40,7 +40,7 @@ module Bundler
deps = begin
parallel_compact_index_client.dependencies(remaining_gems)
rescue TooManyRequestsError
- @bundle_worker.stop if @bundle_worker
+ @bundle_worker&.stop
@bundle_worker = nil # reset it. Not sure if necessary
serial_compact_index_client.dependencies(remaining_gems)
end
@@ -49,7 +49,7 @@ module Bundler
complete_gems.concat(deps.map(&:first)).uniq!
remaining_gems = next_gems - complete_gems
end
- @bundle_worker.stop if @bundle_worker
+ @bundle_worker&.stop
@bundle_worker = nil # reset it. Not sure if necessary
gem_info
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 71faeaf282..39afe8a071 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -95,7 +95,7 @@ module Bundler
def serialized_exception_for(e)
<<-EOS.gsub(/^ {8}/, "")
#{e.class}: #{e.message}
- #{e.backtrace && e.backtrace.join("\n ").chomp}
+ #{e.backtrace&.join("\n ")&.chomp}
EOS
end
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index 0bbd2d9b75..dcf759cded 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -21,7 +21,7 @@ module Bundler
def gemspec(&block)
gemspec = instance.gemspec
- block.call(gemspec) if block
+ block&.call(gemspec)
gemspec
end
end
@@ -152,8 +152,7 @@ module Bundler
def gem_push_host
env_rubygems_host = ENV["RUBYGEMS_HOST"]
- env_rubygems_host = nil if
- env_rubygems_host && env_rubygems_host.empty?
+ env_rubygems_host = nil if env_rubygems_host&.empty?
allowed_push_host || env_rubygems_host || "rubygems.org"
end
@@ -218,7 +217,7 @@ module Bundler
SharedHelpers.chdir(base) do
outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
status = $?
- block.call(outbuf) if status.success? && block
+ block&.call(outbuf) if status.success?
[outbuf, status]
end
end
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index dce7133769..0bbc0f256e 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -96,7 +96,7 @@ module Bundler
handle_error if failed_specs.any?
@specs
ensure
- worker_pool && worker_pool.stop
+ worker_pool&.stop
end
def check_for_unmet_dependencies
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index 6fbd036f38..a2d5eaa38a 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -146,7 +146,7 @@ module Bundler
# @param [Boolean] is the index file global index
def load_index(index_file, global = false)
SharedHelpers.filesystem_access(index_file, :read) do |index_f|
- valid_file = index_f && index_f.exist? && !index_f.size.zero?
+ valid_file = index_f&.exist? && !index_f.size.zero?
break unless valid_file
data = index_f.read
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index 9161c6afde..b6bd24e41c 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -28,8 +28,8 @@ module Bundler
end
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
- @input_engine = engine && engine.to_s
- @engine = engine && engine.to_s || "ruby"
+ @input_engine = engine&.to_s
+ @engine = engine&.to_s || "ruby"
@engine_versions = (engine_version && Array(engine_version)) || @versions
@engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
@patchlevel = patchlevel || (@gem_version.prerelease? ? "-1" : nil)
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index d14075c96b..c67c69266e 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -243,7 +243,7 @@ module Bundler
kernel = (class << ::Kernel; self; end)
[kernel, ::Kernel].each do |kernel_class|
redefine_method(kernel_class, :gem) do |dep, *reqs|
- if executables && executables.include?(File.basename(caller.first.split(":").first))
+ if executables&.include?(File.basename(caller.first.split(":").first))
break
end
diff --git a/lib/bundler/ui/rg_proxy.rb b/lib/bundler/ui/rg_proxy.rb
index ef6def225b..b17ca65f53 100644
--- a/lib/bundler/ui/rg_proxy.rb
+++ b/lib/bundler/ui/rg_proxy.rb
@@ -12,7 +12,7 @@ module Bundler
end
def say(message)
- @ui && @ui.debug(message)
+ @ui&.debug(message)
end
end
end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 70e317089c..7c03d8687f 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.4.1".freeze
+ VERSION = "2.5.0.dev".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index f6c92d52ab..ee1b8856a2 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require "rbconfig"
module Gem
- VERSION = "3.4.1".freeze
+ VERSION = "3.5.0.dev".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@@ -857,8 +857,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Returns the version of the latest release-version of gem +name+
def self.latest_version_for(name)
- spec = latest_spec_for name
- spec && spec.version
+ latest_spec_for(name)&.version
end
##
diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb
index f6fad0bd83..d47573ead6 100644
--- a/lib/rubygems/bundler_version_finder.rb
+++ b/lib/rubygems/bundler_version_finder.rb
@@ -47,7 +47,7 @@ module Gem::BundlerVersionFinder
def self.lockfile_contents
gemfile = ENV["BUNDLE_GEMFILE"]
- gemfile = nil if gemfile && gemfile.empty?
+ gemfile = nil if gemfile&.empty?
unless gemfile
begin
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 3477422b79..d4078aaf5b 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -70,8 +70,7 @@ module Gem::GemcutterUtilities
@host ||=
begin
env_rubygems_host = ENV["RUBYGEMS_HOST"]
- env_rubygems_host = nil if
- env_rubygems_host && env_rubygems_host.empty?
+ env_rubygems_host = nil if env_rubygems_host&.empty?
env_rubygems_host || configured_host
end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 4672866985..050ffbfe77 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -616,8 +616,7 @@ EOM
verify_checksums @digests, @checksums
- @security_policy.verify_signatures @spec, @digests, @signatures if
- @security_policy
+ @security_policy&.verify_signatures @spec, @digests, @signatures
true
rescue Gem::Security::Exception
diff --git a/lib/rubygems/request_set/lockfile/parser.rb b/lib/rubygems/request_set/lockfile/parser.rb
index 8446f9df8e..2d98c9520b 100644
--- a/lib/rubygems/request_set/lockfile/parser.rb
+++ b/lib/rubygems/request_set/lockfile/parser.rb
@@ -331,7 +331,7 @@ class Gem::RequestSet::Lockfile::Parser
set.find_all(requirement)
end.compact.first
- specification && specification.version
+ specification&.version
end
##
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 5175db2d84..31b8ef9546 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1041,7 +1041,7 @@ class Gem::Specification < Gem::BasicSpecification
next if s.activated?
s.contains_requirable_file? path
end
- stub && stub.to_spec
+ stub&.to_spec
end
def self.find_active_stub_by_path(path)
@@ -1626,7 +1626,7 @@ class Gem::Specification < Gem::BasicSpecification
builder.build_extensions
end
ensure
- ui.close if ui
+ ui&.close
Gem::Specification.unresolved_deps.replace unresolved_deps
end
end
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 2fa505423b..69de05fa24 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -290,7 +290,7 @@ class Gem::StreamUI
@outs.flush
result = @ins.gets
- result.chomp! if result
+ result&.chomp!
result
end
@@ -305,7 +305,7 @@ class Gem::StreamUI
password = _gets_noecho
@outs.puts
- password.chomp! if password
+ password&.chomp!
password
end
diff --git a/spec/bundler/realworld/fixtures/warbler/Gemfile.lock b/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
index 8f29bd341f..5b476f8df2 100644
--- a/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
+++ b/spec/bundler/realworld/fixtures/warbler/Gemfile.lock
@@ -27,4 +27,4 @@ DEPENDENCIES
warbler (~> 2.0)
BUNDLED WITH
- 2.4.0.dev
+ 2.5.0.dev
diff --git a/spec/bundler/support/artifice/vcr.rb b/spec/bundler/support/artifice/vcr.rb
index e5be1e3d70..8428391688 100644
--- a/spec/bundler/support/artifice/vcr.rb
+++ b/spec/bundler/support/artifice/vcr.rb
@@ -42,7 +42,7 @@ class BundlerVCRHTTP < Net::HTTP
response.uri = request.uri
response.reading_body(response_io, request.response_body_permitted?) do
- response_block.call(response) if response_block
+ response_block&.call(response)
end
end
end
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index 45a5a14251..aab875fec9 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -1612,7 +1612,7 @@ class Object
if val_or_callable.respond_to? :call
val_or_callable.call(*args, &blk)
else
- blk.call(*block_args) if blk
+ blk&.call(*block_args)
val_or_callable
end
end
diff --git a/tool/bundler/dev_gems.rb.lock b/tool/bundler/dev_gems.rb.lock
index 0e266cdcb5..694109aada 100644
--- a/tool/bundler/dev_gems.rb.lock
+++ b/tool/bundler/dev_gems.rb.lock
@@ -54,4 +54,4 @@ DEPENDENCIES
webrick (~> 1.6)
BUNDLED WITH
- 2.4.1
+ 2.5.0.dev
diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock
index 00300554d0..6f888e1d10 100644
--- a/tool/bundler/rubocop_gems.rb.lock
+++ b/tool/bundler/rubocop_gems.rb.lock
@@ -70,4 +70,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
- 2.4.1
+ 2.5.0.dev
diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock
index aaeae355d9..d74de2452b 100644
--- a/tool/bundler/standard_gems.rb.lock
+++ b/tool/bundler/standard_gems.rb.lock
@@ -78,4 +78,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
- 2.4.1
+ 2.5.0.dev
diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock
index 4918f113ae..16e25ffd5c 100644
--- a/tool/bundler/test_gems.rb.lock
+++ b/tool/bundler/test_gems.rb.lock
@@ -42,4 +42,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
- 2.4.1
+ 2.5.0.dev