diff options
author | Hiroshi SHIBATA <[email protected]> | 2022-08-03 12:24:38 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2022-08-03 13:14:10 +0900 |
commit | 71794a75db5d3da810146da106baf7eb5e86f745 (patch) | |
tree | c354ae515036c15a96a079712f3b7427c807be18 | |
parent | 8a1be433e8cac6ca5ded095f6fefbdc1009102b9 (diff) |
Merge rubygems/bundler HEAD
Pick from https://github.com/rubygems/rubygems/commit/8331e63263081a6aa690d8025d2957f30c4e814a
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6209
27 files changed, 46 insertions, 42 deletions
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb index 068c765aad..16d4e0145a 100644 --- a/lib/bundler/cli/platform.rb +++ b/lib/bundler/cli/platform.rb @@ -9,7 +9,7 @@ module Bundler def run platforms, ruby_version = Bundler.ui.silence do - locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version + 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] diff --git a/lib/bundler/cli/viz.rb b/lib/bundler/cli/viz.rb index 644f9b25cf..5c09e00995 100644 --- a/lib/bundler/cli/viz.rb +++ b/lib/bundler/cli/viz.rb @@ -23,7 +23,7 @@ module Bundler Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:" Bundler.ui.warn "`gem install ruby-graphviz`" rescue StandardError => e - raise unless e.message =~ /GraphViz not installed or dot not in PATH/ + raise unless e.message.to_s.include?("GraphViz not installed or dot not in PATH") Bundler.ui.error e.message Bundler.ui.warn "Please install GraphViz. On a Mac with Homebrew, you can run `brew install graphviz`." end diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb index 2e4ebb37ee..8dd8a53815 100644 --- a/lib/bundler/constants.rb +++ b/lib/bundler/constants.rb @@ -2,6 +2,6 @@ module Bundler WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/ - FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/ + FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd") NULL = WINDOWS ? "NUL" : "/dev/null" end diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index f2aad3a500..0a668eb17c 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -68,7 +68,7 @@ module Bundler raise CertificateFailureError.new(uri) rescue *HTTP_ERRORS => e Bundler.ui.trace e - if e.is_a?(SocketError) || e.message =~ /host down:/ + if e.is_a?(SocketError) || e.message.to_s.include?("host down:") raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \ "connection and try again." else diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable index f6487e3c89..9ff6f00898 100644 --- a/lib/bundler/templates/Executable +++ b/lib/bundler/templates/Executable @@ -13,7 +13,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir bundle_binstub = File.expand_path("bundle", __dir__) if File.file?(bundle_binstub) - if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler index 51650c7664..77f90e735c 100644 --- a/lib/bundler/templates/Executable.bundler +++ b/lib/bundler/templates/Executable.bundler @@ -62,8 +62,9 @@ m = Module.new do def bundler_requirement @bundler_requirement ||= - env_var_version || cli_arg_version || - bundler_requirement_for(lockfile_version) + env_var_version || + cli_arg_version || + bundler_requirement_for(lockfile_version) end def bundler_requirement_for(version) diff --git a/lib/bundler/templates/Executable.standalone b/lib/bundler/templates/Executable.standalone index d591e3fc04..3117a27e86 100644 --- a/lib/bundler/templates/Executable.standalone +++ b/lib/bundler/templates/Executable.standalone @@ -1,4 +1,6 @@ #!/usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %> +# frozen_string_literal: true + # # This file was generated by Bundler. # diff --git a/lib/rubygems.rb b/lib/rubygems.rb index e59cd26870..b21f00acc7 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1010,7 +1010,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Is this platform Solaris? def self.solaris_platform? - RUBY_PLATFORM =~ /solaris/ + RUBY_PLATFORM.include?("solaris") end ## diff --git a/lib/rubygems/commands/rdoc_command.rb b/lib/rubygems/commands/rdoc_command.rb index 17ad6f836b..a998a9704c 100644 --- a/lib/rubygems/commands/rdoc_command.rb +++ b/lib/rubygems/commands/rdoc_command.rb @@ -86,8 +86,9 @@ Use --overwrite to force rebuilding of documentation. begin doc.generate rescue Errno::ENOENT => e - e.message =~ / - / - alert_error "Unable to document #{spec.full_name}, #{$'} is missing, skipping" + match = / - /.match(e.message) + alert_error "Unable to document #{spec.full_name}, " \ + " #{match.post_match} is missing, skipping" terminate_interaction 1 if specs.length == 1 end end diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index d27f286265..b805ef9174 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -171,7 +171,7 @@ module Gem def self.default_exec_format exec_format = RbConfig::CONFIG["ruby_install_name"].sub("ruby", "%s") rescue "%s" - unless exec_format =~ /%s/ + unless exec_format.include?("%s") raise Gem::Exception, "[BUG] invalid exec_format #{exec_format.inspect}, no %s" end diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index c5a03806b9..b46f9b5cd5 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -26,7 +26,7 @@ class Gem::Ext::Builder RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/ make_program_name = ENV["MAKE"] || ENV["make"] || $1 unless make_program_name - make_program_name = (/mswin/ =~ RUBY_PLATFORM) ? "nmake" : "make" + make_program_name = (RUBY_PLATFORM.include?("mswin")) ? "nmake" : "make" end make_program = Shellwords.split(make_program_name) diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 52307f6d93..8ec75d1ff7 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -234,8 +234,8 @@ class Gem::Installer io.gets # blankline # TODO detect a specially formatted comment instead of trying - # to run a regexp against Ruby code. - next unless io.gets =~ /This file was generated by RubyGems/ + # to find a string inside Ruby code. + next unless io.gets.to_s.include?("This file was generated by RubyGems") ruby_executable = true existing = io.read.slice(%r{ diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb index 60104a34d5..1609924607 100644 --- a/lib/rubygems/validator.rb +++ b/lib/rubygems/validator.rb @@ -26,7 +26,7 @@ class Gem::Validator Find.find gem_directory do |file_name| fn = file_name[gem_directory.size..file_name.size - 1].sub(/^\//, "") installed_files << fn unless - fn =~ /CVS/ || fn.empty? || File.directory?(file_name) + fn.empty? || fn.include?("CVS") || File.directory?(file_name) end installed_files diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/commands/platform_spec.rb index 691a219e62..0b964eac8c 100644 --- a/spec/bundler/other/platform_spec.rb +++ b/spec/bundler/commands/platform_spec.rb @@ -231,7 +231,7 @@ G L bundle "platform --ruby" - expect(out).to eq("ruby 1.0.0p127") + expect(out).to eq("ruby 1.0.0") end it "handles when there is a requirement in the gemfile" do diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb index 62f3722a39..ee98bcd4d7 100644 --- a/spec/bundler/quality_spec.rb +++ b/spec/bundler/quality_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "The library itself" do def check_for_tab_characters(filename) failing_lines = [] each_line(filename) do |line, number| - failing_lines << number + 1 if line =~ /\t/ + failing_lines << number + 1 if line.include?("\t") end return if failing_lines.empty? diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb index 30c922efb0..2a667011a1 100644 --- a/spec/bundler/realworld/edgecases_spec.rb +++ b/spec/bundler/realworld/edgecases_spec.rb @@ -218,7 +218,7 @@ RSpec.describe "real world edgecases", :realworld => true do end it "doesn't hang on big gemfile" do - skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3" || RUBY_PLATFORM =~ /darwin/ + skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3" || RUBY_PLATFORM.include?("darwin") gemfile <<~G # frozen_string_literal: true @@ -330,7 +330,7 @@ RSpec.describe "real world edgecases", :realworld => true do end it "doesn't hang on tricky gemfile" do - skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3" || RUBY_PLATFORM =~ /darwin/ + skip "Only for ruby 2.7.3" if RUBY_VERSION != "2.7.3" || RUBY_PLATFORM.include?("darwin") gemfile <<~G source 'https://rubygems.org' @@ -356,7 +356,7 @@ RSpec.describe "real world edgecases", :realworld => true do end it "doesn't hang on nix gemfile" do - skip "Only for ruby 3.0.1" if RUBY_VERSION != "3.0.1" || RUBY_PLATFORM =~ /darwin/ + skip "Only for ruby 3.0.1" if RUBY_VERSION != "3.0.1" || RUBY_PLATFORM.include?("darwin") gemfile <<~G source "https://rubygems.org" do diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 4390f0fb17..29445b420c 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -370,7 +370,7 @@ RSpec.describe "Bundler.setup" do context "when the ruby stdlib is a substring of Gem.path" do it "does not reject the stdlib from $LOAD_PATH" do - substring = "/" + $LOAD_PATH.find {|p| p =~ /vendor_ruby/ }.split("/")[2] + substring = "/" + $LOAD_PATH.find {|p| p.include?("vendor_ruby") }.split("/")[2] run "puts 'worked!'", :env => { "GEM_PATH" => substring } expect(out).to eq("worked!") end @@ -865,7 +865,7 @@ end gemspec_content = File.binread(gemspec). sub("Bundler::VERSION", %("#{Bundler::VERSION}")). - lines.reject {|line| line =~ %r{lib/bundler/version} }.join + lines.reject {|line| line.include?("lib/bundler/version") }.join File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f| f.write(gemspec_content) diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb index dab3cd4d4c..46eefbb48e 100644 --- a/test/rubygems/helper.rb +++ b/test/rubygems/helper.rb @@ -270,7 +270,7 @@ class Gem::TestCase < Test::Unit::TestCase end def assert_contains_make_command(target, output, msg = nil) - if output.match(/\n/) + if output.include?("\n") msg = build_message(msg, "Expected output containing make command \"%s\", but was \n\nBEGIN_OF_OUTPUT\n%sEND_OF_OUTPUT" % [ ("%s %s" % [make_command, target]).rstrip, diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb index b061666c76..3d7f616519 100644 --- a/test/rubygems/test_bundled_ca.rb +++ b/test/rubygems/test_bundled_ca.rb @@ -36,7 +36,7 @@ class TestBundledCA < Gem::TestCase pend "#{host} seems offline, I can't tell whether ssl would work." rescue OpenSSL::SSL::SSLError => e # Only fail for certificate verification errors - if e.message =~ /certificate verify failed/ + if e.message.include?("certificate verify failed") flunk "#{host} is not verifiable using the included certificates. Error was: #{e.message}" end raise diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb index 0e21e460f6..60e2b65047 100644 --- a/test/rubygems/test_gem_bundler_version_finder.rb +++ b/test/rubygems/test_gem_bundler_version_finder.rb @@ -78,7 +78,7 @@ class TestGemBundlerVersionFinder < Gem::TestCase def test_deleted_directory pend "Cannot perform this test on windows" if win_platform? - pend "Cannot perform this test on Solaris" if /solaris/ =~ RUBY_PLATFORM + pend "Cannot perform this test on Solaris" if RUBY_PLATFORM.include?("solaris") require "tmpdir" orig_dir = Dir.pwd diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb index 6adfd42550..34d8903595 100644 --- a/test/rubygems/test_gem_ext_builder.rb +++ b/test/rubygems/test_gem_ext_builder.rb @@ -106,7 +106,7 @@ install: end def test_build_extensions - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + pend if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") # not working from the beginning @spec.extensions << "ext/extconf.rb" ext_dir = File.join @spec.gem_dir, "ext" @@ -142,7 +142,7 @@ install: end def test_build_extensions_with_gemhome_with_space - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + pend if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") # not working from the beginning new_gemhome = File.join @tempdir, "gem home" File.rename(@gemhome, new_gemhome) @gemhome = new_gemhome @@ -163,7 +163,7 @@ install: false end end - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + pend if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") # not working from the beginning @spec.extensions << "ext/extconf.rb" diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb index 5a940b07a8..c6bbab2cb3 100644 --- a/test/rubygems/test_gem_ext_cargo_builder.rb +++ b/test/rubygems/test_gem_ext_cargo_builder.rb @@ -164,7 +164,7 @@ class TestGemExtCargoBuilder < Gem::TestCase def skip_unsupported_platforms! pend "jruby not supported" if java_platform? pend "truffleruby not supported (yet)" if RUBY_ENGINE == "truffleruby" - pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") + pend "mswin not supported (yet)" if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") system(@rust_envs, "cargo", "-V", out: IO::NULL, err: [:child, :out]) pend "cargo not present" unless $?.success? pend "ruby.h is not provided by ruby repo" if ruby_repo? diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 4600317578..d269644ade 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1490,7 +1490,7 @@ gem 'other', version def test_install_extension_and_script pend "Makefile creation crashes on jruby" if Gem.java_platform? - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + pend if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") # not working from the beginning @spec = setup_base_spec @spec.extensions << "extconf.rb" diff --git a/test/rubygems/test_gem_requirement.rb b/test/rubygems/test_gem_requirement.rb index 5ecdbeddae..29bb264454 100644 --- a/test/rubygems/test_gem_requirement.rb +++ b/test/rubygems/test_gem_requirement.rb @@ -83,7 +83,7 @@ class TestGemRequirement < Gem::TestCase Gem::Requirement.parse(Gem::Version.new("2")) end - if RUBY_VERSION >= "2.5" && !(Gem.java_platform? && ENV["JRUBY_OPTS"] =~ /--debug/) + if RUBY_VERSION >= "2.5" && !(Gem.java_platform? && ENV["JRUBY_OPTS"].to_s.include?("--debug")) def test_parse_deduplication assert_same "~>", Gem::Requirement.parse("~> 1").first end diff --git a/test/rubygems/test_gem_resolver_git_specification.rb b/test/rubygems/test_gem_resolver_git_specification.rb index fef071aa76..454fd9c6e4 100644 --- a/test/rubygems/test_gem_resolver_git_specification.rb +++ b/test/rubygems/test_gem_resolver_git_specification.rb @@ -63,7 +63,7 @@ class TestGemResolverGitSpecification < Gem::TestCase def test_install_extension pend if Gem.java_platform? - pend if /mswin/ =~ RUBY_PLATFORM && ENV.key?("GITHUB_ACTIONS") # not working from the beginning + pend if RUBY_PLATFORM.include?("mswin") && ENV.key?("GITHUB_ACTIONS") # not working from the beginning name, _, repository, = git_gem "a", 1 do |s| s.extensions << "ext/extconf.rb" end diff --git a/test/rubygems/test_gem_security_trust_dir.rb b/test/rubygems/test_gem_security_trust_dir.rb index 8c59286679..b74e21fb5c 100644 --- a/test/rubygems/test_gem_security_trust_dir.rb +++ b/test/rubygems/test_gem_security_trust_dir.rb @@ -70,7 +70,7 @@ class TestGemSecurityTrustDir < Gem::TestCase assert_path_exist @dest_dir mask = 040700 & (~File.umask) - mask |= 0200000 if /aix/ =~ RUBY_PLATFORM + mask |= 0200000 if RUBY_PLATFORM.include?("aix") assert_equal mask, File.stat(@dest_dir).mode unless win_platform? end @@ -91,7 +91,7 @@ class TestGemSecurityTrustDir < Gem::TestCase @trust_dir.verify mask = 040700 & (~File.umask) - mask |= 0200000 if /aix/ =~ RUBY_PLATFORM + mask |= 0200000 if RUBY_PLATFORM.include?("aix") assert_equal mask, File.stat(@dest_dir).mode unless win_platform? end diff --git a/test/rubygems/test_kernel.rb b/test/rubygems/test_kernel.rb index cced65fa50..091a5419fb 100644 --- a/test/rubygems/test_kernel.rb +++ b/test/rubygems/test_kernel.rb @@ -20,7 +20,7 @@ class TestKernel < Gem::TestCase def test_gem assert gem("a", "= 1"), "Should load" - assert $:.any? {|p| %r{a-1/lib} =~ p } + assert $:.any? {|p| p.include?("a-1/lib") } end def test_gem_default @@ -50,13 +50,13 @@ class TestKernel < Gem::TestCase def test_gem_redundant assert gem("a", "= 1"), "Should load" refute gem("a", "= 1"), "Should not load" - assert_equal 1, $:.select {|p| %r{a-1/lib} =~ p }.size + assert_equal 1, $:.select {|p| p.include?("a-1/lib") }.size end def test_gem_overlapping assert gem("a", "= 1"), "Should load" refute gem("a", ">= 1"), "Should not load" - assert_equal 1, $:.select {|p| %r{a-1/lib} =~ p }.size + assert_equal 1, $:.select {|p| p.include?("a-1/lib") }.size end def test_gem_prerelease @@ -83,13 +83,13 @@ class TestKernel < Gem::TestCase assert_match(/activated a-1/, ex.message) assert_equal "a", ex.name - assert $:.any? {|p| %r{a-1/lib} =~ p } - refute $:.any? {|p| %r{a-2/lib} =~ p } + assert $:.any? {|p| p.include?("a-1/lib") } + refute $:.any? {|p| p.include?("a-2/lib") } end def test_gem_not_adding_bin assert gem("a", "= 1"), "Should load" - refute $:.any? {|p| %r{a-1/bin} =~ p } + refute $:.any? {|p| p.include?("a-1/bin") } end def test_gem_failing_inside_require_doesnt_cause_double_exceptions @@ -114,7 +114,7 @@ class TestKernel < Gem::TestCase quick_gem "bundler", "2.a" assert gem("bundler") - assert $:.any? {|p| %r{bundler-1/lib} =~ p } + assert $:.any? {|p| p.include?("bundler-1/lib") } end def test_gem_bundler_inferred_bundler_version @@ -123,7 +123,7 @@ class TestKernel < Gem::TestCase quick_gem "bundler", "2.a" assert gem("bundler", ">= 0.a") - assert $:.any? {|p| %r{bundler-1/lib} =~ p } + assert $:.any? {|p| p.include?("bundler-1/lib") } end end end |