diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-08-19 18:08:52 -0400 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-08-20 16:18:26 -0400 |
commit | 9ed5fc491f5093a19a953f679e461556d28b43a7 (patch) | |
tree | 37c4050a8d792cdf6e5edfff994dd61d56f5c013 | |
parent | aea4046b5b91b83b27f117822e1bd6c614da3e6e (diff) | |
download | bundler-9ed5fc491f5093a19a953f679e461556d28b43a7.tar.gz |
[Update] Avoid a normal update when running with only --bundlerseg-bundle-update-bundler-no-reresolve
-rw-r--r-- | lib/bundler/cli/update.rb | 3 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 12 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 2 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 21 |
4 files changed, 34 insertions, 4 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 73caae387f..9b2d55c1b9 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -45,7 +45,8 @@ module Bundler end Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby], - :lock_shared_dependencies => options[:conservative]) + :lock_shared_dependencies => options[:conservative], + :bundler => options[:bundler]) end Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index fea66f4245..1385ff2a94 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -55,7 +55,15 @@ module Bundler # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version # @param optional_groups [Array(String)] A list of optional groups def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = []) - @unlocking = unlock == true || !unlock.empty? + if [true, false].include?(unlock) + @unlocking_bundler = false + @unlocking = unlock + else + unlock = unlock.dup + @unlocking_bundler = unlock.delete(:bundler) + unlock.delete_if {|_k, v| Array(v).empty? } + @unlocking = !unlock.empty? + end @dependencies = dependencies @sources = sources @@ -326,7 +334,7 @@ module Bundler end end - preserve_unknown_sections ||= !updating_major && (Bundler.frozen? || !unlocking?) + preserve_unknown_sections ||= !updating_major && (Bundler.frozen? || !(unlocking? || @unlocking_bundler)) return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections) if Bundler.frozen? diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 18debb72fe..2bb405bc7a 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -266,7 +266,7 @@ module Bundler # returns whether or not a re-resolve was needed def resolve_if_needed(options) - if !options["update"] && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file? + if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file? return false if @definition.nothing_changed? && !@definition.missing_specs? end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 2e6abfa9a5..a488be536f 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -629,6 +629,27 @@ RSpec.describe "bundle update --ruby" do end end +RSpec.describe "bundle update --bundler" do + it "updates the bundler version in the lockfile without re-resolving" do + build_repo4 do + build_gem "rack", "1.0" + end + + install_gemfile! <<-G + source "file:#{gem_repo4}" + gem "rack" + G + lockfile lockfile.sub(Bundler::VERSION, "1.0.0") + + FileUtils.rm_r gem_repo4 + + bundle! :update, :bundler => true, :verbose => true + expect(the_bundle).to include_gem "rack 1.0" + + expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION) + end +end + # these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that. RSpec.describe "bundle update conservative" do context "patch and minor options" do |