Skip to content

Commit

Permalink
Merge pull request #4030 from rubygems/no_minimal_deps
Browse files Browse the repository at this point in the history
Expose `--no-minimal-deps` flag to install the latest version of dependencies
  • Loading branch information
deivid-rodriguez committed Oct 26, 2020
2 parents 715aa04 + df80801 commit ad9f9d1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems/dependency_installer.rb
Expand Up @@ -285,7 +285,7 @@ def resolve_dependencies(dep_or_name, version) # :nodoc:
request_set.prerelease = @prerelease

installer_set = Gem::Resolver::InstallerSet.new @domain
installer_set.ignore_installed = @only_install_dir
installer_set.ignore_installed = (@minimal_deps == false) || @only_install_dir

if consider_local?
if dep_or_name =~ /\.gem$/ and File.file? dep_or_name
Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/install_update_options.rb
Expand Up @@ -122,10 +122,10 @@ def add_install_update_options
options[:minimal_deps] = true
end

add_option(:"Install/Update", "--minimal-deps",
add_option(:"Install/Update", "--[no-]minimal-deps",
"Don't upgrade any dependencies that already",
"meet version requirements") do |value, options|
options[:minimal_deps] = true
options[:minimal_deps] = value
end

add_option(:"Install/Update", "--[no-]post-install-message",
Expand Down
34 changes: 34 additions & 0 deletions test/rubygems/test_gem_dependency_installer.rb
Expand Up @@ -528,6 +528,40 @@ def test_install_minimal_deps
assert_equal %w[a-1 e-1], inst.installed_gems.map {|s| s.full_name }
end

def test_install_no_minimal_deps
util_setup_gems

_, e1_gem = util_gem 'e', '1' do |s|
s.add_dependency 'b'
end

_, b2_gem = util_gem 'b', '2' do |s|
s.add_dependency 'a'
end

FileUtils.mv @a1_gem, @tempdir
FileUtils.mv @b1_gem, @tempdir
FileUtils.mv b2_gem, @tempdir
FileUtils.mv e1_gem, @tempdir

inst = nil

Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new :ignore_dependencies => true
inst.install 'b', req('= 1')
end

assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name },
'sanity check'

Dir.chdir @tempdir do
inst = Gem::DependencyInstaller.new :minimal_deps => false
inst.install 'e'
end

assert_equal %w[a-1 b-2 e-1], inst.installed_gems.map {|s| s.full_name }
end

def test_install_no_document
util_setup_gems

Expand Down
12 changes: 12 additions & 0 deletions test/rubygems/test_gem_install_update_options.rb
Expand Up @@ -192,4 +192,16 @@ def test_post_install_message

assert_equal true, @cmd.options[:post_install_message]
end

def test_minimal_deps_no
@cmd.handle_options %w[--no-minimal-deps]

assert_equal false, @cmd.options[:minimal_deps]
end

def test_minimal_deps
@cmd.handle_options %w[--minimal-deps]

assert_equal true, @cmd.options[:minimal_deps]
end
end

0 comments on commit ad9f9d1

Please sign in to comment.