Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ def converge_locked_specs
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
Expand All @@ -762,7 +764,7 @@ def converge_locked_specs
# 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.
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.settings_flag(flag, &default)
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)
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Settings
plugins
prefer_gems_rb
silence_root_warning
unlock_source_unlocks_spec
update_requires_all_flag
].freeze

Expand Down
3 changes: 3 additions & 0 deletions man/bundle-config.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
15 changes: 15 additions & 0 deletions spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@
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
Expand Down