summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli/update.rb15
-rw-r--r--spec/commands/update_spec.rb18
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}"