diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-15 16:05:47 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-18 20:51:09 -0500 |
commit | 8d94491dcebc10e1a354f37501beacea8511272d (patch) | |
tree | a86204eb6c8d90c381b1781ab24a65035665abca | |
parent | 69d18afc202f28ceb98f436c25532d02f9d4c1d6 (diff) | |
download | bundler-8d94491dcebc10e1a354f37501beacea8511272d.tar.gz |
Add a feature flag for `bundle update —source NAME` not unlocking a gem with that nameseg-update-source-feature-flag
-rw-r--r-- | lib/bundler/definition.rb | 4 | ||||
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 1 | ||||
-rw-r--r-- | man/bundle-config.ronn | 3 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 15 |
5 files changed, 23 insertions, 1 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index d7faff53e7..0e39cf710c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -748,6 +748,8 @@ module Bundler end end + unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec? + converged = [] @locked_specs.each do |s| # Replace the locked dependency's source with the equivalent source from the Gemfile @@ -762,7 +764,7 @@ module Bundler # XXX This is a backwards-compatibility fix to preserve the ability to # unlock a single gem by passing its name via `--source`. See issue #3759 # TODO: delete in Bundler 2 - next if @unlock[:sources].include?(s.name) + next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name) # If the spec is from a path source and it doesn't exist anymore # then we unlock it. diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 34fddb1ecc..b07ea49679 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -20,6 +20,7 @@ module Bundler settings_flag(:only_update_to_newer_versions) { bundler_2_mode? } settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } settings_flag(:prefer_gems_rb) { bundler_2_mode? } + settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? } settings_flag(:update_requires_all_flag) { bundler_2_mode? } def initialize(bundler_version) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 9f4d5b30a0..e0eb660a8a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -30,6 +30,7 @@ module Bundler plugins prefer_gems_rb silence_root_warning + unlock_source_unlocks_spec update_requires_all_flag ].freeze diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 4fa0025815..c8a1391d3e 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -228,6 +228,9 @@ learn more about their operation in [bundle install(1)][bundle-install]. Generate a `gems.rb` instead of a `Gemfile` when running `bundle init`. * `prefer_gems_rb` (`BUNDLE_PREFER_GEMS_RB`) Prefer `gems.rb` to `Gemfile` when Bundler is searching for a Gemfile. +* `unlock_source_unlocks_spec` (`BUNDLE_UNLOCK_SOURCE_UNLOCKS_SPEC`): + Whether running `bundle update --source NAME` unlocks a gem with the given + name. Defaults to `true`. * `update_requires_all_flag` (`BUNDLE_UPDATE_REQUIRES_ALL_FLAG`) Require passing `--all` to `bundle update` when everything should be updated, and disallow passing no options to `bundle update`. diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index b0a55ab930..ce3eede732 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -216,6 +216,21 @@ RSpec.describe "bundle update" do bundle "update --source activesupport" expect(the_bundle).to include_gems "activesupport 3.0" end + + context "with unlock_source_unlocks_spec set to false" do + before { bundle! "config unlock_source_unlocks_spec false" } + + it "should not update gems not included in the source that happen to have the same name" do + install_gemfile <<-G + source "file://#{gem_repo2}" + gem "activesupport" + G + update_repo2 { build_gem "activesupport", "3.0" } + + bundle "update --source activesupport" + expect(the_bundle).not_to include_gems "activesupport 3.0" + end + end end context "when there is a child dependency that is also in the gemfile" do |