mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add Gem.disable_system_update_message to disable gem update --system if needed.
This commit is contained in:
parent
49c42b6012
commit
3ab1cfc325
Notes:
git
2020-06-15 21:21:01 +09:00
3 changed files with 28 additions and 0 deletions
|
@ -1187,6 +1187,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|||
# other.
|
||||
class << self
|
||||
|
||||
##
|
||||
# RubyGems distributors (like operating system package managers) can
|
||||
# disable RubyGems update by setting this to error message printed to
|
||||
# end-users on gem update --system instead of actual update.
|
||||
attr_accessor :disable_system_update_message
|
||||
|
||||
##
|
||||
# Hash of loaded Gem::Specification keyed by name
|
||||
|
||||
|
|
|
@ -262,6 +262,11 @@ command to remove old versions.
|
|||
# Update RubyGems software to the latest version.
|
||||
|
||||
def update_rubygems
|
||||
if Gem.disable_system_update_message
|
||||
alert_error Gem.disable_system_update_message
|
||||
return
|
||||
end
|
||||
|
||||
check_update_arguments
|
||||
|
||||
version, requirement = rubygems_target_version
|
||||
|
|
|
@ -238,6 +238,23 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
|
|||
@ui.error
|
||||
end
|
||||
|
||||
def test_execute_system_with_disabled_update
|
||||
old_disable_system_update_message = Gem.disable_system_update_message
|
||||
Gem.disable_system_update_message = "Please use package manager instead."
|
||||
|
||||
@cmd.options[:args] = []
|
||||
@cmd.options[:system] = true
|
||||
|
||||
use_ui @ui do
|
||||
@cmd.execute
|
||||
end
|
||||
|
||||
assert_empty @ui.output
|
||||
assert_equal "ERROR: Please use package manager instead.\n", @ui.error
|
||||
ensure
|
||||
Gem.disable_system_update_message = old_disable_system_update_message
|
||||
end
|
||||
|
||||
# before:
|
||||
# a1 -> c1.2
|
||||
# after:
|
||||
|
|
Loading…
Reference in a new issue