mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 03:24:00 +02:00
Merge pull request #5482 from hsbt/rubygems-3-3-bundler-2-3
Merge RubyGems 3.3.x and Bundler 2.3.x
This commit is contained in:
parent
69463805f0
commit
6794f8cf92
115 changed files with 1701 additions and 889 deletions
|
@ -8,7 +8,12 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|||
include Gem::VersionOption
|
||||
|
||||
def initialize
|
||||
super 'fetch', 'Download a gem and place it in the current directory'
|
||||
defaults = {
|
||||
:suggest_alternate => true,
|
||||
:version => Gem::Requirement.default,
|
||||
}
|
||||
|
||||
super 'fetch', 'Download a gem and place it in the current directory', defaults
|
||||
|
||||
add_bulk_threshold_option
|
||||
add_proxy_option
|
||||
|
@ -18,6 +23,10 @@ class Gem::Commands::FetchCommand < Gem::Command
|
|||
add_version_option
|
||||
add_platform_option
|
||||
add_prerelease_option
|
||||
|
||||
add_option '--[no-]suggestions', 'Suggest alternates when gems are not found' do |value, options|
|
||||
options[:suggest_alternate] = value
|
||||
end
|
||||
end
|
||||
|
||||
def arguments # :nodoc:
|
||||
|
@ -42,15 +51,27 @@ then repackaging it.
|
|||
"#{program_name} GEMNAME [GEMNAME ...]"
|
||||
end
|
||||
|
||||
def check_version # :nodoc:
|
||||
if options[:version] != Gem::Requirement.default and
|
||||
get_all_gem_names.size > 1
|
||||
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
|
||||
" version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
|
||||
terminate_interaction 1
|
||||
end
|
||||
end
|
||||
|
||||
def execute
|
||||
version = options[:version] || Gem::Requirement.default
|
||||
check_version
|
||||
version = options[:version]
|
||||
|
||||
platform = Gem.platforms.last
|
||||
gem_names = get_all_gem_names
|
||||
gem_names = get_all_gem_names_and_versions
|
||||
|
||||
gem_names.each do |gem_name|
|
||||
dep = Gem::Dependency.new gem_name, version
|
||||
gem_names.each do |gem_name, gem_version|
|
||||
gem_version ||= version
|
||||
dep = Gem::Dependency.new gem_name, gem_version
|
||||
dep.prerelease = options[:prerelease]
|
||||
suppress_suggestions = !options[:suggest_alternate]
|
||||
|
||||
specs_and_sources, errors =
|
||||
Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
||||
|
@ -63,12 +84,10 @@ then repackaging it.
|
|||
spec, source = specs_and_sources.max_by {|s,| s }
|
||||
|
||||
if spec.nil?
|
||||
show_lookup_failure gem_name, version, errors, options[:domain]
|
||||
show_lookup_failure gem_name, gem_version, errors, suppress_suggestions, options[:domain]
|
||||
next
|
||||
end
|
||||
|
||||
source.download spec
|
||||
|
||||
say "Downloaded #{spec.full_name}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue