summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-04-24 11:58:40 +0000
committerBundlerbot <bot@bundler.io>2019-04-24 11:58:40 +0000
commitec8f98574a90de1e87a50e00141180d761f161dc (patch)
tree1b9e8c22bda415035ef8ed010191eb0897790fe5
parentdea7c6dcc3658d4f7ffcebdd7147076b017dc8db (diff)
parent6df7af763cb3d8b13568ca12199ca778cccbe405 (diff)
downloadbundler-ec8f98574a90de1e87a50e00141180d761f161dc.tar.gz
Merge #6329
6329: Stop printing “failed to update” message when changing sources r=segiddins a=segiddins ### What was the end-user problem that led to this PR? The problem was `bundle update` shows incorrect message when updating git gems Closes #6325 ### What was your diagnosis of the problem? My diagnosis was we need to check if the source has changed ### What is your fix for the problem, implemented in this PR? My fix only prints the message when the source has not changed Note that is does not yet fix the "updated the git sha" case, since the locked spec and the new spec actually share the same source object! Co-authored-by: Samuel Giddins <segiddins@segiddins.me> Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
-rw-r--r--lib/bundler/cli/update.rb23
-rw-r--r--spec/commands/update_spec.rb33
2 files changed, 50 insertions, 6 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 13d71bb50e..45d0374eef 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -58,6 +58,14 @@ module Bundler
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
Bundler.definition.validate_runtime!
+
+ if locked_gems = Bundler.definition.locked_gems
+ previous_locked_specs = locked_gems.specs.reduce({}) do |h, s|
+ h[s.name] = { :version => s.version, :source => s.source.to_s }
+ h
+ end
+ end
+
installer = Installer.install Bundler.root, Bundler.definition, opts
Bundler.load.cache if Bundler.app_cache.exist?
@@ -66,13 +74,16 @@ module Bundler
Bundler::CLI::Clean.new(options).run
end
- if locked_gems = Bundler.definition.locked_gems
+ if locked_gems
gems.each do |name|
- locked_version = locked_gems.specs.find {|s| s.name == name }
- locked_version &&= locked_version.version
- next unless locked_version
- new_version = Bundler.definition.specs[name].first
- new_version &&= new_version.version
+ locked_spec = previous_locked_specs[name]
+ next unless locked_spec
+ locked_source = locked_spec[:source]
+ locked_version = locked_spec[:version]
+ new_spec = Bundler.definition.specs[name].first
+ new_source = new_spec.source.to_s
+ new_version = new_spec.version
+ next if locked_source != new_source
if !new_version
Bundler.ui.warn "Bundler attempted to update #{name} but it was removed from the bundle"
elsif new_version < locked_version
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index d78ee26c1f..735d8cd8de 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -473,6 +473,39 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
end
+ it "will not warn when an explicitly updated git gem changes sha but not version" do
+ build_git "foo"
+
+ install_gemfile! <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ update_git "foo" do |s|
+ s.write "lib/foo2.rb", "puts :foo2"
+ end
+
+ bundle! "update foo"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
+ it "will not warn when changing gem sources but not versions" do
+ build_git "rack"
+
+ install_gemfile! <<-G
+ gem "rack", :git => '#{lib_path("rack-1.0")}'
+ G
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle! "update rack"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
it "will update only from pinned source" do
install_gemfile <<-G
source "file://#{gem_repo2}"