Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

--newer-only option for install/update #4511

Closed
2 tasks
coilysiren opened this issue May 3, 2016 · 1 comment
Closed
2 tasks

--newer-only option for install/update #4511

coilysiren opened this issue May 3, 2016 · 1 comment

Comments

@coilysiren
Copy link
Contributor

coilysiren commented May 3, 2016

From: rubygems/bundler-features#73

Involves:

  • setting a flag in 1.X
  • changing the default update behavior in 2.0
@segiddins
Copy link
Member

diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 36bb9f2..f2f8f49 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -249,7 +249,7 @@ module Bundler
         else
           # Run a resolve against the locally available gems
           Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
-          last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, ruby_version, gem_version_promoter)
+          last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, resolver_base_set(last_resolve), ruby_version, gem_version_promoter)
         end
       end
     end
@@ -633,6 +633,18 @@ module Bundler
       Set.new(@dependencies) != Set.new(@locked_deps)
     end

+    LockedSpec = Struct.new(:name, :version)
+
+    def resolver_base_set(converged_locked_specs)
+      base = converged_locked_specs.to_hash
+      @locked_specs.each do |spec|
+        if base[spec.name].empty?
+          base[spec.name] << LockedSpec.new(spec.name, ">= #{spec.version}")
+        end
+      end
+      base.values.flatten
+    end
+
     # Remove elements from the locked specs that are expired. This will most
     # commonly happen if the Gemfile has changed since the lockfile was last
     # generated
@@ -707,7 +719,6 @@ module Bundler
           source.unlock! if !diff.empty? && diff.any? {|s| s.source == source }
         end
       end
-
       resolve
     end

I believe this should be the gist of it, but it's untested

This was referenced Aug 9, 2016
homu added a commit that referenced this issue Aug 20, 2016
Block resolving to older versions during an update

This is currently behind the only_update_to_newer_versions setting

Closes #4511.

See #4856 and #4871
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants