Import remaining changes

The "sync with commits" scripts failed to properly import these for some
reason.
This commit is contained in:
David Rodríguez 2020-07-01 20:22:40 +02:00 committed by Hiroshi SHIBATA
parent 0c8d90b526
commit 5783d0dbfc
Notes: git 2020-07-15 16:05:42 +09:00
10 changed files with 67 additions and 53 deletions

View File

@ -136,14 +136,10 @@ module Bundler
end end
def inflate(obj) def inflate(obj)
require "rubygems/util"
Gem::Util.inflate(obj) Gem::Util.inflate(obj)
end end
def correct_for_windows_path(path) def correct_for_windows_path(path)
require "rubygems/util"
if Gem::Util.respond_to?(:correct_for_windows_path) if Gem::Util.respond_to?(:correct_for_windows_path)
Gem::Util.correct_for_windows_path(path) Gem::Util.correct_for_windows_path(path)
elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":" elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"

View File

@ -194,7 +194,7 @@ module Bundler
return @md5_available if defined?(@md5_available) return @md5_available if defined?(@md5_available)
@md5_available = begin @md5_available = begin
require "openssl" require "openssl"
OpenSSL::Digest::MD5.digest("") OpenSSL::Digest.digest("MD5", "")
true true
rescue LoadError rescue LoadError
true true

View File

@ -344,13 +344,6 @@ class Bundler::Thor
command && disable_required_check.include?(command.name.to_sym) command && disable_required_check.include?(command.name.to_sym)
end end
def deprecation_warning(message) #:nodoc:
unless ENV['THOR_SILENCE_DEPRECATION']
warn "Deprecation warning: #{message}\n" +
'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
end
end
protected protected
def stop_on_unknown_option #:nodoc: def stop_on_unknown_option #:nodoc:

View File

@ -33,7 +33,8 @@ class Bundler::Thor
# Boolean:: true if it is identical, false otherwise. # Boolean:: true if it is identical, false otherwise.
# #
def identical? def identical?
exists? && File.identical?(render, destination) source = File.expand_path(render, File.dirname(destination))
exists? && File.identical?(source, destination)
end end
def invoke! def invoke!

View File

@ -22,6 +22,15 @@ class Bundler::Thor
TEMPLATE_EXTNAME = ".tt" TEMPLATE_EXTNAME = ".tt"
class << self
def deprecation_warning(message) #:nodoc:
unless ENV['THOR_SILENCE_DEPRECATION']
warn "Deprecation warning: #{message}\n" +
'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
end
end
end
module Base module Base
attr_accessor :options, :parent_options, :args attr_accessor :options, :parent_options, :args

View File

@ -1,3 +1,3 @@
class Bundler::Thor class Bundler::Thor
VERSION = "1.0.0" VERSION = "1.0.1"
end end

View File

@ -65,7 +65,7 @@ RSpec.describe Bundler::Fetcher::CompactIndex do
context "when FIPS-mode is active" do context "when FIPS-mode is active" do
before do before do
allow(OpenSSL::Digest::MD5).to receive(:digest). allow(OpenSSL::Digest).to receive(:digest).with("MD5", "").
and_raise(OpenSSL::Digest::DigestError) and_raise(OpenSSL::Digest::DigestError)
end end

View File

@ -602,7 +602,7 @@ RSpec.describe "Bundler.setup" do
end end
G G
install_gems "activesupport-2.3.5" system_gems "activesupport-2.3.5"
expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => :default expect(the_bundle).to include_gems "activesupport 2.3.2", :groups => :default
end end
@ -618,7 +618,7 @@ RSpec.describe "Bundler.setup" do
end end
G G
install_gems "activesupport-2.3.5" system_gems "activesupport-2.3.5"
expect(the_bundle).to include_gems "activesupport 2.3.2" expect(the_bundle).to include_gems "activesupport 2.3.2"
end end
@ -765,7 +765,7 @@ end
full_gem_name = gem_name + "-1.0" full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp("extensions", full_gem_name)) ext_dir = File.join(tmp("extensions", full_gem_name))
install_gems full_gem_name system_gems full_gem_name
install_gemfile <<-G install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo1)}"

View File

@ -99,14 +99,11 @@ RSpec.configure do |config|
FileUtils.cp_r pristine_system_gem_path, system_gem_path FileUtils.cp_r pristine_system_gem_path, system_gem_path
with_gem_path_as(system_gem_path) do with_gem_path_as(system_gem_path) do
@command_executions = []
Bundler.ui.silence { example.run } Bundler.ui.silence { example.run }
all_output = @command_executions.map(&:to_s_verbose).join("\n\n") all_output = all_commands_output
if example.exception && !all_output.empty? if example.exception && !all_output.empty?
warn all_output unless config.formatters.grep(RSpec::Core::Formatters::DocumentationFormatter).empty? message = example.exception.message + all_output
message = example.exception.message + "\n\nCommands:\n#{all_output}"
(class << example.exception; self; end).send(:define_method, :message) do (class << example.exception; self; end).send(:define_method, :message) do
message message
end end

View File

@ -27,8 +27,12 @@ module Spec
TheBundle.new(*args) TheBundle.new(*args)
end end
def command_executions
@command_executions ||= []
end
def last_command def last_command
@command_executions.last || raise("There is no last command") command_executions.last || raise("There is no last command")
end end
def out def out
@ -189,18 +193,36 @@ module Spec
stderr_read_thread = Thread.new { stderr.read } stderr_read_thread = Thread.new { stderr.read }
command_execution.stdout = stdout_read_thread.value.strip command_execution.stdout = stdout_read_thread.value.strip
command_execution.stderr = stderr_read_thread.value.strip command_execution.stderr = stderr_read_thread.value.strip
command_execution.exitstatus = wait_thr && wait_thr.value.exitstatus
end
(@command_executions ||= []) << command_execution status = wait_thr.value
command_execution.exitstatus = if status.exited?
status.exitstatus
elsif status.signaled?
128 + status.termsig
end
end
unless options[:raise_on_error] == false || command_execution.success? unless options[:raise_on_error] == false || command_execution.success?
raise "Invoking #{cmd} failed!" raise <<~ERROR
Invoking `#{cmd}` failed with output:
----------------------------------------------------------------------
#{command_execution.stdboth}
----------------------------------------------------------------------
ERROR
end end
command_executions << command_execution
command_execution.stdout command_execution.stdout
end end
def all_commands_output
return [] if command_executions.empty?
"\n\nCommands:\n#{command_executions.map(&:to_s_verbose).join("\n\n")}"
end
def config(config = nil, path = bundled_app(".bundle/config")) def config(config = nil, path = bundled_app(".bundle/config"))
return YAML.load_file(path) unless config return YAML.load_file(path) unless config
FileUtils.mkdir_p(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path))
@ -264,9 +286,12 @@ module Spec
bundle :lock, opts bundle :lock, opts
end end
def install_gems(*gems) def system_gems(*gems)
gems = gems.flatten
options = gems.last.is_a?(Hash) ? gems.pop : {} options = gems.last.is_a?(Hash) ? gems.pop : {}
gem_repo = options.fetch(:gem_repo) { gem_repo1 } path = options.fetch(:path, system_gem_path)
with_gem_path_as(path) do
gem_repo = options.fetch(:gem_repo, gem_repo1)
gems.each do |g| gems.each do |g|
gem_name = g.to_s gem_name = g.to_s
if gem_name.start_with?("bundler") if gem_name.start_with?("bundler")
@ -279,6 +304,7 @@ module Spec
end end
end end
end end
end
def install_gem(path) def install_gem(path)
raise "OMG `#{path}` does not exist!" unless File.exist?(path) raise "OMG `#{path}` does not exist!" unless File.exist?(path)
@ -384,20 +410,12 @@ module Spec
system_gems(*gems) system_gems(*gems)
end end
def system_gems(*gems)
opts = gems.last.is_a?(Hash) ? gems.last : {}
path = opts.fetch(:path, system_gem_path)
gems = gems.flatten
with_gem_path_as(path) do
install_gems(*gems)
end
end
def realworld_system_gems(*gems) def realworld_system_gems(*gems)
gems = gems.flatten gems = gems.flatten
opts = gems.last.is_a?(Hash) ? gems.pop : {}
path = opts.fetch(:path, system_gem_path)
with_gem_path_as(system_gem_path) do with_gem_path_as(path) do
gems.each do |gem| gems.each do |gem|
gem_command "install --no-document #{gem}" gem_command "install --no-document #{gem}"
end end
@ -494,11 +512,11 @@ module Spec
process_file(pathname) do |line| process_file(pathname) do |line|
case line case line
when /spec\.metadata\["(?:allowed_push_host|homepage_uri|source_code_uri|changelog_uri)"\]/, /spec\.homepage/ when /spec\.metadata\["(?:allowed_push_host|homepage_uri|source_code_uri|changelog_uri)"\]/, /spec\.homepage/
line.gsub(/\=.*$/, "= 'http://example.org'") line.gsub(/\=.*$/, '= "http://example.org"')
when /spec\.summary/ when /spec\.summary/
line.gsub(/\=.*$/, "= %q{A short summary of my new gem.}") line.gsub(/\=.*$/, '= "A short summary of my new gem."')
when /spec\.description/ when /spec\.description/
line.gsub(/\=.*$/, "= %q{A longer description of my new gem.}") line.gsub(/\=.*$/, '= "A longer description of my new gem."')
else else
line line
end end