summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-08-27 20:37:34 +0000
committerThe Bundler Bot <bot@bundler.io>2017-08-27 20:37:34 +0000
commit5686af6ee463eddbc97fe50b893129690f271013 (patch)
tree83d51008190bd19fa588f15d8c3f25c582d2cbc8
parent3203fdd2ad861af2aedfa233b754a02bfc1c4741 (diff)
parent9ed5fc491f5093a19a953f679e461556d28b43a7 (diff)
downloadbundler-5686af6ee463eddbc97fe50b893129690f271013.tar.gz
Auto merge of #5956 - bundler:seg-bundle-update-bundler-no-reresolve, r=indirect
[Update] Avoid a normal update when running with only --bundler ### What was the end-user problem that led to this PR? The problem was `bundle update --bundler` went through the full update/resolution path when really we just want to pin to a different bundler version. ### What was your diagnosis of the problem? My diagnosis was we should just update the lockfile, without threading the rest of the process like an update. This implements what @indirect requested in https://github.com/rubygems/rubygems/pull/1977#issuecomment-322852799.
-rw-r--r--lib/bundler/cli/update.rb3
-rw-r--r--lib/bundler/definition.rb12
-rw-r--r--lib/bundler/installer.rb2
-rw-r--r--spec/commands/update_spec.rb21
4 files changed, 34 insertions, 4 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 26ee192aa9..b57b82ecc1 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