summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-02-01 11:14:04 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-02-01 11:14:57 +0900
commit600a715c9bde99fe2e9a669465d78833445273e8 (patch)
tree8244622e8cc02b40dd0dad29d30fc60a11342396 /lib/rubygems/commands
parentadc303131187654d8ce83f3db17eefa3d5bae26c (diff)
Merge the current master branch of rubygems/rubygems.
Just started to develop RubyGems 3.2.0.
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r--lib/rubygems/commands/help_command.rb2
-rw-r--r--lib/rubygems/commands/info_command.rb13
-rw-r--r--lib/rubygems/commands/install_command.rb6
-rw-r--r--lib/rubygems/commands/list_command.rb15
-rw-r--r--lib/rubygems/commands/pristine_command.rb12
-rw-r--r--lib/rubygems/commands/search_command.rb14
-rw-r--r--lib/rubygems/commands/setup_command.rb19
-rw-r--r--lib/rubygems/commands/sources_command.rb6
-rw-r--r--lib/rubygems/commands/update_command.rb37
9 files changed, 92 insertions, 32 deletions
diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb
index 9f14e22f90..259e8b5622 100644
--- a/lib/rubygems/commands/help_command.rb
+++ b/lib/rubygems/commands/help_command.rb
@@ -38,7 +38,7 @@ Some examples of 'gem' usage.
* Create a gem:
- See http://guides.rubygems.org/make-your-own-gem/
+ See https://guides.rubygems.org/make-your-own-gem/
* See information about RubyGems:
diff --git a/lib/rubygems/commands/info_command.rb b/lib/rubygems/commands/info_command.rb
index 6a737b178b..a64843405e 100644
--- a/lib/rubygems/commands/info_command.rb
+++ b/lib/rubygems/commands/info_command.rb
@@ -1,14 +1,19 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
+require 'rubygems/query_utils'
-class Gem::Commands::InfoCommand < Gem::Commands::QueryCommand
+class Gem::Commands::InfoCommand < Gem::Command
+
+ include Gem::QueryUtils
def initialize
- super "info", "Show information for the given gem"
+ super "info", "Show information for the given gem",
+ :name => //, :domain => :local, :details => false, :versions => true,
+ :installed => nil, :version => Gem::Requirement.default
+
+ add_query_options
- remove_option('--name-matches')
remove_option('-d')
defaults[:details] = true
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 753ff33eb5..6f9a8d2a08 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -218,7 +218,7 @@ You can use `i` command instead of `install`.
gem_version ||= options[:version]
domain = options[:domain]
domain = :local unless options[:suggest_alternate]
- supress_suggestions = (domain == :local)
+ suppress_suggestions = (domain == :local)
begin
install_gem gem_name, gem_version
@@ -226,11 +226,11 @@ You can use `i` command instead of `install`.
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
rescue Gem::GemNotFoundException => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions
+ show_lookup_failure e.name, e.version, e.errors, suppress_suggestions
exit_code |= 2
rescue Gem::UnsatisfiableDependencyError => e
- show_lookup_failure e.name, e.version, e.errors, supress_suggestions,
+ show_lookup_failure e.name, e.version, e.errors, suppress_suggestions,
"'#{gem_name}' (#{gem_version})"
exit_code |= 2
diff --git a/lib/rubygems/commands/list_command.rb b/lib/rubygems/commands/list_command.rb
index cd21543537..f94038920f 100644
--- a/lib/rubygems/commands/list_command.rb
+++ b/lib/rubygems/commands/list_command.rb
@@ -1,17 +1,20 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
+require 'rubygems/query_utils'
##
-# An alternate to Gem::Commands::QueryCommand that searches for gems starting
-# with the supplied argument.
+# Searches for gems starting with the supplied argument.
-class Gem::Commands::ListCommand < Gem::Commands::QueryCommand
+class Gem::Commands::ListCommand < Gem::Command
+
+ include Gem::QueryUtils
def initialize
- super 'list', 'Display local gems whose name matches REGEXP'
+ super 'list', 'Display local gems whose name matches REGEXP',
+ :name => //, :domain => :local, :details => false, :versions => true,
+ :installed => nil, :version => Gem::Requirement.default
- remove_option('--name-matches')
+ add_query_options
end
def arguments # :nodoc:
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 2248a821c8..d10060923f 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -40,6 +40,11 @@ class Gem::Commands::PristineCommand < Gem::Command
options[:only_executables] = value
end
+ add_option('--only-plugins',
+ 'Only restore plugins') do |value, options|
+ options[:only_plugins] = value
+ end
+
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
'of /usr/bin/env') do |value, options|
@@ -126,14 +131,14 @@ extensions will be restored.
end
end
- unless spec.extensions.empty? or options[:extensions] or options[:only_executables]
+ unless spec.extensions.empty? or options[:extensions] or options[:only_executables] or options[:only_plugins]
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end
gem = spec.cache_file
- unless File.exist? gem or options[:only_executables]
+ unless File.exist? gem or options[:only_executables] or options[:only_plugins]
require 'rubygems/remote_fetcher'
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
@@ -172,6 +177,9 @@ extensions will be restored.
if options[:only_executables]
installer = Gem::Installer.for_spec(spec, installer_options)
installer.generate_bin
+ elsif options[:only_plugins]
+ installer = Gem::Installer.for_spec(spec)
+ installer.generate_plugins
else
installer = Gem::Installer.at(gem, installer_options)
installer.install
diff --git a/lib/rubygems/commands/search_command.rb b/lib/rubygems/commands/search_command.rb
index c9cb1f2d43..65ee25167c 100644
--- a/lib/rubygems/commands/search_command.rb
+++ b/lib/rubygems/commands/search_command.rb
@@ -1,15 +1,17 @@
# frozen_string_literal: true
require 'rubygems/command'
-require 'rubygems/commands/query_command'
+require 'rubygems/query_utils'
-class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
+class Gem::Commands::SearchCommand < Gem::Command
- def initialize
- super 'search', 'Display remote gems whose name matches REGEXP'
+ include Gem::QueryUtils
- remove_option '--name-matches'
+ def initialize
+ super 'search', 'Display remote gems whose name matches REGEXP',
+ :name => //, :domain => :remote, :details => false, :versions => true,
+ :installed => nil, :version => Gem::Requirement.default
- defaults[:domain] = :remote
+ add_query_options
end
def arguments # :nodoc:
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 579776df7e..d67caca91c 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -20,7 +20,8 @@ class Gem::Commands::SetupCommand < Gem::Command
:force => true,
:site_or_vendor => 'sitelibdir',
:destdir => '', :prefix => '', :previous_version => '',
- :regenerate_binstubs => true
+ :regenerate_binstubs => true,
+ :regenerate_plugins => true
add_option '--previous-version=VERSION',
'Previous version of RubyGems',
@@ -89,6 +90,11 @@ class Gem::Commands::SetupCommand < Gem::Command
options[:regenerate_binstubs] = value
end
+ add_option '--[no-]regenerate-plugins',
+ 'Regenerate gem plugins' do |value, options|
+ options[:regenerate_plugins] = value
+ end
+
add_option '-f', '--[no-]force',
'Forcefully overwrite binstubs' do |value, options|
options[:force] = value
@@ -181,6 +187,7 @@ By default, this RubyGems will install gem as:
say "RubyGems #{Gem::VERSION} installed"
regenerate_binstubs if options[:regenerate_binstubs]
+ regenerate_plugins if options[:regenerate_plugins]
uninstall_old_gemcutter
@@ -626,6 +633,16 @@ abort "#{deprecation_message}"
command.invoke(*args)
end
+ def regenerate_plugins
+ require "rubygems/commands/pristine_command"
+ say "Regenerating plugins"
+
+ args = %w[--all --only-plugins --silent]
+
+ command = Gem::Commands::PristineCommand.new
+ command.invoke(*args)
+ end
+
private
def target_bin_path(bin_dir, bin_file)
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index feab23237d..ca9d425232 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -136,7 +136,7 @@ RubyGems has been configured to serve gems via the following URLs through
its history:
* http://gems.rubyforge.org (RubyGems 1.3.6 and earlier)
-* http://rubygems.org (RubyGems 1.3.7 through 1.8.25)
+* https://rubygems.org/ (RubyGems 1.3.7 through 1.8.25)
* https://rubygems.org (RubyGems 2.0.1 and newer)
Since all of these sources point to the same set of gems you only need one
@@ -153,8 +153,8 @@ before it is added.
To remove a source use the --remove argument:
- $ gem sources --remove http://rubygems.org
- http://rubygems.org removed from sources
+ $ gem sources --remove https://rubygems.org/
+ https://rubygems.org/ removed from sources
EOF
end
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index e8031a259d..7031ac0dd0 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -73,8 +73,6 @@ command to remove old versions.
say "Latest version already installed. Done."
terminate_interaction
end
-
- options[:user_install] = false
end
def check_update_arguments # :nodoc:
@@ -90,9 +88,10 @@ command to remove old versions.
return
end
- hig = highest_installed_gems
-
- gems_to_update = which_to_update hig, options[:args].uniq
+ gems_to_update = which_to_update(
+ highest_installed_gems,
+ options[:args].uniq
+ )
if options[:explain]
say "Gems to update:"
@@ -137,6 +136,9 @@ command to remove old versions.
def highest_installed_gems # :nodoc:
hig = {} # highest installed gems
+ # Get only gem specifications installed as --user-install
+ Gem::Specification.dirs = Gem.user_dir if options[:user_install]
+
Gem::Specification.each do |spec|
if hig[spec.name].nil? or hig[spec.name].version < spec.version
hig[spec.name] = spec
@@ -168,11 +170,34 @@ command to remove old versions.
Dir.chdir update_dir do
say "Installing RubyGems #{version}"
- installed = system Gem.ruby, '--disable-gems', 'setup.rb', *args
+ installed = preparing_gem_layout_for(version) do
+ system Gem.ruby, '--disable-gems', 'setup.rb', *args
+ end
+
say "RubyGems system software updated" if installed
end
end
+ def preparing_gem_layout_for(version)
+ if Gem::Version.new(version) >= Gem::Version.new("3.2.a")
+ yield
+ else
+ require "tmpdir"
+ tmpdir = Dir.mktmpdir
+ FileUtils.mv Gem.plugins_dir, tmpdir
+
+ status = yield
+
+ if status
+ FileUtils.rm_rf tmpdir
+ else
+ FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugins_dir
+ end
+
+ status
+ end
+ end
+
def rubygems_target_version
version = options[:system]
update_latest = version == true