Skip to content

Commit

Permalink
[Update] Warn when an explicitly updated spec does not get a newer ve…
Browse files Browse the repository at this point in the history
…rsion
  • Loading branch information
segiddins committed Jul 27, 2017
1 parent 92f7781 commit 618c09b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/bundler/cli/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ def run
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
Expand Down
18 changes: 18 additions & 0 deletions spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,24 @@
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}"
Expand Down

0 comments on commit 618c09b

Please sign in to comment.