[rubygems/rubygems] Add bundle lock --update --bundler

bundle lock --update can do everything that bundle update can do, but
it doesn't actually install gems. This is especially useful for
generating a lockfile on a machine that doesn't have the libraries
available to be able to build native extensions.

But, there was no parallel for bundle update --bundler. So let's add
one.

https://github.com/rubygems/rubygems/commit/7fc00bd2a5
This commit is contained in:
Alyssa Ross 2019-01-21 12:10:53 +00:00 committed by git
parent ede7c035d5
commit d4315284e9
3 changed files with 27 additions and 2 deletions

View File

@ -672,6 +672,8 @@ module Bundler
"If updating, do not allow any gem to be updated past latest --patch | --minor | --major" "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
method_option "conservative", :type => :boolean, :banner => method_option "conservative", :type => :boolean, :banner =>
"If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated" "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
"Update the locked version of bundler"
def lock def lock
require_relative "cli/lock" require_relative "cli/lock"
Lock.new(options).run Lock.new(options).run

View File

@ -22,12 +22,15 @@ module Bundler
update = options[:update] update = options[:update]
conservative = options[:conservative] conservative = options[:conservative]
bundler = options[:bundler]
if update.is_a?(Array) # unlocking specific gems if update.is_a?(Array) # unlocking specific gems
Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update) Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
update = { :gems => update, :conservative => conservative } update = { :gems => update, :conservative => conservative }
elsif update elsif update && conservative
update = { :conservative => conservative } if conservative update = { :conservative => conservative }
elsif update && bundler
update = { :bundler => bundler }
end end
definition = Bundler.definition(update) definition = Bundler.definition(update)

View File

@ -212,6 +212,26 @@ RSpec.describe "bundle lock" do
end end
end end
it "updates the bundler version in the lockfile without re-resolving", :rubygems => ">= 3.3.0.dev" do
build_repo4 do
build_gem "rack", "1.0"
end
install_gemfile <<-G
source "#{file_uri_for(gem_repo4)}"
gem "rack"
G
lockfile lockfile.sub(/(^\s*)#{Bundler::VERSION}($)/, '\11.0.0\2')
FileUtils.rm_r gem_repo4
bundle "lock --update --bundler"
expect(the_bundle).to include_gem "rack 1.0"
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION)
end
it "supports adding new platforms" do it "supports adding new platforms" do
bundle "lock --add-platform java x86-mingw32" bundle "lock --add-platform java x86-mingw32"