diff options
author | The Bundler Bot <bot@bundler.io> | 2017-08-14 16:08:48 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-08-14 16:08:48 +0000 |
commit | a41379c5988a97716113f090bf972a71ef19b081 (patch) | |
tree | cdcd9051eb7790cf6d53d53e9d5038e8a86c6ef4 | |
parent | 605beb0a4800c923380f2dfe903f2fd2eee8b7c5 (diff) | |
parent | 618c09b59d1318958c23b1b0031c68c93186851a (diff) | |
download | bundler-a41379c5988a97716113f090bf972a71ef19b081.tar.gz |
Auto merge of #5904 - bundler:seg-explicit-update-warning, r=indirect
[Update] Warn when an explicitly updated spec does not get a newer version
### What was the end-user problem that led to this PR?
The problem was you could run `bundle update foo bar` and it would be possible that either `foo` or `bar` not move to a newer version.
### What was your diagnosis of the problem?
My diagnosis was we should tell users when this happens!
### What is your fix for the problem, implemented in this PR?
My fix warns when a locked bundle has `bundle update` called with an explicit list of gems and one of those gems could not actually be _updated_.
### Why did you choose this fix out of the possible options?
I chose this fix because it didn't require mucking around with the resolved.
-rw-r--r-- | lib/bundler/cli/update.rb | 15 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 18 |
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index fcf5397bf7..73caae387f 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -67,6 +67,21 @@ module Bundler Bundler::CLI::Clean.new(options).run end + if locked_gems = Bundler.definition.locked_gems + gems.each do |name| + locked_version = locked_gems.specs.find {|s| s.name == name }.version + new_version = Bundler.definition.specs[name].first + new_version &&= new_version.version + if !new_version + Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle" + elsif new_version < locked_version + Bundler.ui.warn "Bundler attempted to update #{name} but its version regressed from #{locked_version} to #{new_version}" + elsif new_version == locked_version + Bundler.ui.warn "Bundler attempted to update #{name} but its version stayed the same" + end + end + end + Bundler.ui.confirm "Bundle updated!" Bundler::CLI::Common.output_without_groups_message Bundler::CLI::Common.output_post_install_messages installer.post_install_messages diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index b7e0a17305..2e6abfa9a5 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -373,6 +373,24 @@ RSpec.describe "bundle update in more complicated situations" do expect(the_bundle).to include_gems "thin 2.0", "rack 1.2", "rack-obama 1.0" end + it "will warn when some explicitly updated gems are not updated" do + install_gemfile! <<-G + source "file:#{gem_repo2}" + + gem "thin" + gem "rack-obama" + G + + update_repo2 do + build_gem("thin", "2.0") {|s| s.add_dependency "rack" } + build_gem "rack", "10.0" + end + + bundle! "update thin rack-obama" + expect(last_command.stdboth).to include "Bundler attempted to update rack-obama but its version stayed the same" + expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0" + end + it "will update only from pinned source" do install_gemfile <<-G source "file://#{gem_repo2}" |