зеркало из https://github.com/github/ruby.git
Merge RubyGems 3.1.2
This commit is contained in:
Родитель
fac60be324
Коммит
e672494cd7
|
@ -9,7 +9,7 @@
|
|||
require 'rbconfig'
|
||||
|
||||
module Gem
|
||||
VERSION = "3.1.1".freeze
|
||||
VERSION = "3.1.2".freeze
|
||||
end
|
||||
|
||||
# Must be first since it unloads the prelude from 1.9.2
|
||||
|
|
|
@ -17,6 +17,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|||
|
||||
super 'setup', 'Install RubyGems',
|
||||
:format_executable => true, :document => %w[ri],
|
||||
:force => true,
|
||||
:site_or_vendor => 'sitelibdir',
|
||||
:destdir => '', :prefix => '', :previous_version => '',
|
||||
:regenerate_binstubs => true
|
||||
|
@ -88,6 +89,11 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|||
options[:regenerate_binstubs] = value
|
||||
end
|
||||
|
||||
add_option '-f', '--[no-]force',
|
||||
'Forcefully overwrite binstubs' do |value, options|
|
||||
options[:force] = value
|
||||
end
|
||||
|
||||
add_option('-E', '--[no-]env-shebang',
|
||||
'Rewrite executables with a shebang',
|
||||
'of /usr/bin/env') do |value, options|
|
||||
|
@ -199,10 +205,10 @@ By default, this RubyGems will install gem as:
|
|||
say
|
||||
|
||||
say "RubyGems installed the following executables:"
|
||||
say @bin_file_names.map { |name| "\t#{name}\n" }
|
||||
say bin_file_names.map { |name| "\t#{name}\n" }
|
||||
say
|
||||
|
||||
unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
||||
unless bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
||||
say "If `gem` was installed by a previous RubyGems installation, you may need"
|
||||
say "to remove it by hand."
|
||||
say
|
||||
|
@ -235,8 +241,6 @@ By default, this RubyGems will install gem as:
|
|||
end
|
||||
|
||||
def install_executables(bin_dir)
|
||||
@bin_file_names = []
|
||||
|
||||
prog_mode = options[:prog_mode] || 0755
|
||||
|
||||
executables = { 'gem' => 'bin' }
|
||||
|
@ -249,13 +253,7 @@ By default, this RubyGems will install gem as:
|
|||
bin_files -= %w[update_rubygems]
|
||||
|
||||
bin_files.each do |bin_file|
|
||||
bin_file_formatted = if options[:format_executable]
|
||||
Gem.default_exec_format % bin_file
|
||||
else
|
||||
bin_file
|
||||
end
|
||||
|
||||
dest_file = File.join bin_dir, bin_file_formatted
|
||||
dest_file = target_bin_path(bin_dir, bin_file)
|
||||
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
|
||||
|
||||
begin
|
||||
|
@ -267,7 +265,7 @@ By default, this RubyGems will install gem as:
|
|||
end
|
||||
|
||||
install bin_tmp_file, dest_file, :mode => prog_mode
|
||||
@bin_file_names << dest_file
|
||||
bin_file_names << dest_file
|
||||
ensure
|
||||
rm bin_tmp_file
|
||||
end
|
||||
|
@ -429,13 +427,15 @@ By default, this RubyGems will install gem as:
|
|||
Dir.chdir("bundler") do
|
||||
built_gem = Gem::Package.build(bundler_spec)
|
||||
begin
|
||||
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], install_as_default: true, bin_dir: bin_dir, wrappers: true)
|
||||
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], force: options[:force], install_as_default: true, bin_dir: bin_dir, wrappers: true)
|
||||
installer.install
|
||||
ensure
|
||||
FileUtils.rm_f built_gem
|
||||
end
|
||||
end
|
||||
|
||||
bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
|
||||
|
||||
say "Bundler #{bundler_spec.version} installed"
|
||||
end
|
||||
|
||||
|
@ -592,7 +592,7 @@ abort "#{deprecation_message}"
|
|||
history_string = ""
|
||||
|
||||
until versions.length == 0 or
|
||||
versions.shift < options[:previous_version] do
|
||||
versions.shift <= options[:previous_version] do
|
||||
history_string += version_lines.shift + text.shift
|
||||
end
|
||||
|
||||
|
@ -626,4 +626,19 @@ abort "#{deprecation_message}"
|
|||
command.invoke(*args)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def target_bin_path(bin_dir, bin_file)
|
||||
bin_file_formatted = if options[:format_executable]
|
||||
Gem.default_exec_format % bin_file
|
||||
else
|
||||
bin_file
|
||||
end
|
||||
File.join bin_dir, bin_file_formatted
|
||||
end
|
||||
|
||||
def bin_file_names
|
||||
@bin_file_names ||= []
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -164,6 +164,50 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the
|
||||
# original value when the block ends
|
||||
#
|
||||
def bindir(value)
|
||||
bindir = RbConfig::CONFIG['bindir']
|
||||
|
||||
if value
|
||||
RbConfig::CONFIG['bindir'] = value
|
||||
else
|
||||
RbConfig::CONFIG.delete 'bindir'
|
||||
end
|
||||
|
||||
yield
|
||||
ensure
|
||||
if bindir
|
||||
RbConfig::CONFIG['bindir'] = bindir
|
||||
else
|
||||
RbConfig::CONFIG.delete 'bindir'
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the
|
||||
# original value when the block ends
|
||||
#
|
||||
def exeext(value)
|
||||
exeext = RbConfig::CONFIG['EXEEXT']
|
||||
|
||||
if value
|
||||
RbConfig::CONFIG['EXEEXT'] = value
|
||||
else
|
||||
RbConfig::CONFIG.delete 'EXEEXT'
|
||||
end
|
||||
|
||||
yield
|
||||
ensure
|
||||
if exeext
|
||||
RbConfig::CONFIG['EXEEXT'] = exeext
|
||||
else
|
||||
RbConfig::CONFIG.delete 'EXEEXT'
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: move to minitest
|
||||
def refute_path_exists(path, msg = nil)
|
||||
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
||||
|
|
|
@ -1917,16 +1917,11 @@ You may need to `gem install -g` to install missing gems
|
|||
end
|
||||
|
||||
def with_bindir_and_exeext(bindir, exeext)
|
||||
orig_bindir = RbConfig::CONFIG['bindir']
|
||||
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
|
||||
|
||||
RbConfig::CONFIG['bindir'] = bindir
|
||||
RbConfig::CONFIG['EXEEXT'] = exeext
|
||||
|
||||
yield
|
||||
ensure
|
||||
RbConfig::CONFIG['bindir'] = orig_bindir
|
||||
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
|
||||
bindir(bindir) do
|
||||
exeext(exeext) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def with_clean_path_to_ruby
|
||||
|
|
|
@ -123,6 +123,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
assert_equal "I changed it!\n", File.read(gem_bin_path)
|
||||
end
|
||||
|
||||
def test_execute_informs_about_installed_executables
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
out = @ui.output.split "\n"
|
||||
|
||||
exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
|
||||
assert_equal "\t#{default_gem_bin_path}", out.shift
|
||||
assert_equal "\t#{default_bundle_bin_path}", out.shift
|
||||
end
|
||||
|
||||
def test_env_shebang_flag
|
||||
gem_bin_path = gem_install 'a'
|
||||
write_file gem_bin_path do |io|
|
||||
|
@ -133,10 +145,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
@cmd.options[:env_shebang] = true
|
||||
@cmd.execute
|
||||
|
||||
gem_exec = sprintf Gem.default_exec_format, 'gem'
|
||||
default_gem_bin_path = File.join @install_dir, 'bin', gem_exec
|
||||
bundle_exec = sprintf Gem.default_exec_format, 'bundle'
|
||||
default_bundle_bin_path = File.join @install_dir, 'bin', bundle_exec
|
||||
ruby_exec = sprintf Gem.default_exec_format, 'ruby'
|
||||
|
||||
if Gem.win_platform?
|
||||
|
@ -212,10 +220,41 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
|
||||
# TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
|
||||
|
||||
# expect to not remove bundler-* direcotyr.
|
||||
# expect to not remove bundler-* directory.
|
||||
assert_path_exists 'default/gems/bundler-audit-1.0.0'
|
||||
end
|
||||
|
||||
def test_install_default_bundler_gem_with_force_flag
|
||||
@cmd.extend FileUtils
|
||||
|
||||
bin_dir = File.join(@gemhome, 'bin')
|
||||
bundle_bin = File.join(bin_dir, 'bundle')
|
||||
|
||||
write_file bundle_bin do |f|
|
||||
f.puts '#!/usr/bin/ruby'
|
||||
f.puts ''
|
||||
f.puts 'echo "hello"'
|
||||
end
|
||||
|
||||
bindir(bin_dir) do
|
||||
@cmd.options[:force] = true
|
||||
|
||||
@cmd.install_default_bundler_gem bin_dir
|
||||
|
||||
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
|
||||
default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
|
||||
spec = Gem::Specification.load(default_spec_path)
|
||||
|
||||
spec.executables.each do |e|
|
||||
if Gem.win_platform?
|
||||
assert_path_exists File.join(bin_dir, "#{e}.bat")
|
||||
end
|
||||
|
||||
assert_path_exists File.join bin_dir, Gem.default_exec_format % e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_remove_old_lib_files
|
||||
lib = File.join @install_dir, 'lib'
|
||||
lib_rubygems = File.join lib, 'rubygems'
|
||||
|
@ -308,11 +347,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
* Fixed release note display for LANG=C when installing rubygems
|
||||
* π is tasty
|
||||
|
||||
=== 2.0.2 / 2013-03-06
|
||||
|
||||
* Bug fixes:
|
||||
* Other bugs fixed
|
||||
|
||||
EXPECTED
|
||||
|
||||
output = @ui.output
|
||||
|
@ -323,4 +357,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
@ui.outs.set_encoding @default_external if @default_external
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def default_gem_bin_path
|
||||
gem_exec = sprintf Gem.default_exec_format, 'gem'
|
||||
File.join @install_dir, 'bin', gem_exec
|
||||
end
|
||||
|
||||
def default_bundle_bin_path
|
||||
bundle_exec = sprintf Gem.default_exec_format, 'bundle'
|
||||
File.join @install_dir, 'bin', bundle_exec
|
||||
end
|
||||
|
||||
end unless Gem.java_platform?
|
||||
|
|
|
@ -104,32 +104,19 @@ end
|
|||
def test_check_executable_overwrite_default_bin_dir
|
||||
installer = setup_base_installer
|
||||
|
||||
if defined?(RUBY_FRAMEWORK_VERSION)
|
||||
orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
|
||||
Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
|
||||
end
|
||||
orig_bindir = RbConfig::CONFIG['bindir']
|
||||
RbConfig::CONFIG['bindir'] = Gem.bindir
|
||||
bindir(Gem.bindir) do
|
||||
util_conflict_executable false
|
||||
|
||||
util_conflict_executable false
|
||||
ui = Gem::MockGemUi.new "n\n"
|
||||
use_ui ui do
|
||||
e = assert_raises Gem::InstallError do
|
||||
installer.generate_bin
|
||||
end
|
||||
|
||||
ui = Gem::MockGemUi.new "n\n"
|
||||
use_ui ui do
|
||||
e = assert_raises Gem::InstallError do
|
||||
installer.generate_bin
|
||||
conflicted = File.join @gemhome, 'bin', 'executable'
|
||||
assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
|
||||
e.message
|
||||
end
|
||||
|
||||
conflicted = File.join @gemhome, 'bin', 'executable'
|
||||
assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
|
||||
e.message
|
||||
end
|
||||
ensure
|
||||
Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
|
||||
orig_RUBY_FRAMEWORK_VERSION
|
||||
if orig_bindir
|
||||
RbConfig::CONFIG['bindir'] = orig_bindir
|
||||
else
|
||||
RbConfig::CONFIG.delete 'bindir'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче