summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-06-15 05:41:58 +0000
committerColby Swandale <hello@colby.fyi>2018-08-16 21:42:28 +1000
commitaa65090c78cc7e0b07bce4ef965bf2eb95839a58 (patch)
tree2e208c9b39f97f89d696b3976f437397a169050b
parent12e73cab71647c2bbc8f443c2d899533febfef53 (diff)
downloadbundler-aa65090c78cc7e0b07bce4ef965bf2eb95839a58.tar.gz
Auto merge of #6568 - greysteil:conservative-groups, r=segiddins
Respect --conservative flag when updating a dependency group Previously, we were using `Bundler.definition.specs_for groups` to get the list of dependencies to unlock when updating a specific group. That method returns all sub-dependencies for the dependencies in the group, too, which were therefore being unlocked and --conservative was being ignored. This PR ensures `--conservative` is respected for group updates by selecting the dependencies for the group directly from the definition instead. It adds a test to ensure we don't accidentally regress. Fixes https://github.com/bundler/bundler/issues/6560. (cherry picked from commit c171c54c095a241584aa03c792a9946ec8313c22)
-rw-r--r--lib/bundler/cli/update.rb4
-rw-r--r--spec/commands/update_spec.rb17
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 3890ea307a..903fcb50da 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -38,8 +38,8 @@ module Bundler
Bundler::CLI::Common.ensure_all_gems_in_lockfile!(gems)
if groups.any?
- specs = Bundler.definition.specs_for groups
- gems.concat(specs.map(&:name))
+ deps = Bundler.definition.dependencies.select {|d| (d.groups & groups).any? }
+ gems.concat(deps.map(&:name))
end
Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 6b18d0c8c1..675e8574f1 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -176,6 +176,23 @@ RSpec.describe "bundle update" do
expect(the_bundle).not_to include_gems "rack 1.2"
end
+ context "when conservatively updating a group with non-group sub-deps" do
+ it "should update only specified group gems" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activemerchant", :group => :development
+ gem "activesupport"
+ G
+ update_repo2 do
+ build_gem "activemerchant", "2.0"
+ build_gem "activesupport", "3.0"
+ end
+ bundle "update --conservative --group development"
+ expect(the_bundle).to include_gems "activemerchant 2.0"
+ expect(the_bundle).not_to include_gems "activesupport 3.0"
+ end
+ end
+
context "when there is a source with the same name as a gem in a group" do
before :each do
build_git "foo", :path => lib_path("activesupport")