Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add --minimal-deps to not upgrade deps on install

  • Loading branch information...
commit af3405fd61a9e4087e4e0ed536208638246f72c8 1 parent 950c55c
@evanphx evanphx authored
View
11 lib/rubygems/dependency_installer.rb
@@ -67,6 +67,10 @@ def initialize(options = {})
@user_install = options[:user_install]
@wrappers = options[:wrappers]
+ # Indicates that we should not try to update any deps unless
+ # we absolutely must.
+ @minimal_deps = options[:minimal_deps]
+
@installed_gems = []
@toplevel_specs = nil
@@ -185,6 +189,13 @@ def add_found_dependencies to_do, dependency_list
deps.each do |dep|
dependencies[dep.name] = dependencies[dep.name].merge dep
+ if @minimal_deps
+ next if Gem::Specification.any? do |installed_spec|
+ dep.name == installed_spec.name and
+ dep.requirement.satisfied_by? installed_spec.version
+ end
+ end
+
results = find_gems_with_sources(dep).reverse
results.reject! do |dep_spec,|
View
7 lib/rubygems/install_update_options.rb
@@ -122,6 +122,13 @@ def add_install_update_options
"Don't attempt to upgrade gems already",
"meeting version requirement") do |value, options|
options[:conservative] = true
+ options[:minimal_deps] = true
+ end
+
+ add_option(:"Install/Update", "--minimal-deps",
+ "Don't upgrade any dependencies that already",
+ "meet version requirements") do |value, options|
+ options[:minimal_deps] = true
end
end
View
28 test/rubygems/test_gem_dependency_installer.rb
@@ -77,6 +77,34 @@ def test_install_all_dependencies
assert_equal %w[e-1 a-1], inst.installed_gems.map { |s| s.full_name }
end
+ def test_install_ignore_satified_deps
+ util_setup_gems
+
+ _, e1_gem = util_gem 'e', '1' do |s|
+ s.add_dependency 'b'
+ end
+
+ util_clear_gems
+
+ FileUtils.mv @a1_gem, @tempdir
+ FileUtils.mv @b1_gem, @tempdir
+ FileUtils.mv e1_gem, @tempdir
+
+ Dir.chdir @tempdir do
+ i = Gem::DependencyInstaller.new :ignore_dependencies => true
+ i.install 'b'
+ end
+
+ inst = nil
+
+ Dir.chdir @tempdir do
+ inst = Gem::DependencyInstaller.new :minimal_deps => true
+ inst.install 'e'
+ end
+
+ assert_equal %w[e-1], inst.installed_gems.map { |s| s.full_name }
+ end
+
def test_install_cache_dir
util_setup_gems
Please sign in to comment.
Something went wrong with that request. Please try again.