diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-03-31 13:17:07 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-04-03 20:57:19 -0500 |
commit | 6e25694cafeb697c200d981d5bced45e8b693cca (patch) | |
tree | f5010b02e9b8171994aad8f4b5eae7ea684f6c90 | |
parent | c91e77cab2d29f3e0ecb721430ee93c7c86f0859 (diff) | |
download | bundler-6e25694cafeb697c200d981d5bced45e8b693cca.tar.gz |
[Runtime] Avoid re-locking when not unlocking and nothing has changed
-rw-r--r-- | lib/bundler/definition.rb | 16 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 1 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index d6bbb97606..99cf1ee4e5 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -123,7 +123,7 @@ module Bundler def create_gem_version_promoter locked_specs = - if @unlocking && @locked_specs.empty? && !@lockfile_contents.empty? + if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty? # Definition uses an empty set of locked_specs to indicate all gems # are unlocked, but GemVersionPromoter needs the locked_specs # for conservative comparison. @@ -226,7 +226,7 @@ module Bundler def resolve @resolve ||= begin last_resolve = converge_locked_specs - if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?) + if Bundler.settings[:frozen] || (!unlocking? && nothing_changed?) Bundler.ui.debug("Found no changes, using resolution from the lockfile") last_resolve else @@ -295,7 +295,7 @@ module Bundler end end - preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !@unlocking) + preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !unlocking?) return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) if Bundler.settings[:frozen] @@ -526,14 +526,18 @@ module Bundler attr_reader :sources private :sources - private - def nothing_changed? !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes end + def unlocking? + @unlocking + end + + private + def change_reason - if @unlocking + if unlocking? unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v| if v == true k.to_s diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index fdd3d227e3..6ccb0d89b5 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -127,6 +127,7 @@ module Bundler definition_method :requires def lock(opts = {}) + return if @definition.nothing_changed? && !@definition.unlocking? @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections]) end |