diff options
author | David RodrÃguez <[email protected]> | 2020-04-28 16:28:52 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2020-09-28 14:54:22 +0900 |
commit | c6bdf750499491d12c947de546c164a854dd0703 (patch) | |
tree | a6dcad2cb1e96f21b80946dcda6e393a73d34bec /lib/rubygems/commands/update_command.rb | |
parent | 828cefd629e036c96fbd50013965f61df39417ce (diff) |
Disallow downgrades to too old versions
Consider the version original included with each ruby as the minimum
supported version.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3599
Diffstat (limited to 'lib/rubygems/commands/update_command.rb')
-rw-r--r-- | lib/rubygems/commands/update_command.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb index bac9c82fc8..a822f095bf 100644 --- a/lib/rubygems/commands/update_command.rb +++ b/lib/rubygems/commands/update_command.rb @@ -74,6 +74,13 @@ command to remove old versions. end end + def check_oldest_rubygems(version) # :nodoc: + if oldest_supported_version > version + alert_error "rubygems #{version} is not supported. The oldest supported version is #{oldest_supported_version}" + terminate_interaction 1 + end + end + def check_update_arguments # :nodoc: unless options[:args].empty? alert_error "Gem names are not allowed with the --system option" @@ -214,7 +221,7 @@ command to remove old versions. rubygems_update.version = version hig = { - 'rubygems-update' => rubygems_update + 'rubygems-update' => rubygems_update, } gems_to_update = which_to_update hig, options[:args], :system @@ -272,6 +279,8 @@ command to remove old versions. check_latest_rubygems version + check_oldest_rubygems version + update_gem 'rubygems-update', version installed_gems = Gem::Specification.find_all_by_name 'rubygems-update', requirement @@ -309,4 +318,10 @@ command to remove old versions. result end + + private + + def oldest_supported_version + @oldest_supported_version ||= Gem::Version.new("2.5.2") + end end |