diff options
author | The Bundler Bot <bot@bundler.io> | 2017-06-01 21:26:30 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-01 23:55:32 -0500 |
commit | f3271845acd8b6d135d5957a70d539fe3a1f6635 (patch) | |
tree | b07b812694f56aebd77c004b1ac01e89e78e37b4 /lib | |
parent | 388fde46c180c4e2b569329c9b962dea4ccc8671 (diff) | |
download | bundler-f3271845acd8b6d135d5957a70d539fe3a1f6635.tar.gz |
Auto merge of #5694 - bundler:seg-lock-update-missing, r=colby-swandale
[CLI::Lock] Fail gracefully when updating a missing gem
Closes #5693 by behaving the same way `bundle update` handles gems that aren't in the lockfile
(cherry picked from commit 2e46e6705770e5a4685b1f3d3fbbe60f957599ae)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli/common.rb | 7 | ||||
-rw-r--r-- | lib/bundler/cli/lock.rb | 5 | ||||
-rw-r--r-- | lib/bundler/cli/update.rb | 7 |
3 files changed, 12 insertions, 7 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index c1e108d752..bacbb2edc5 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -70,6 +70,13 @@ module Bundler message end + def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems) + locked_names = locked_gems.specs.map(&:name) + names.-(locked_names).each do |g| + raise GemNotFound, gem_not_found_message(g, locked_names) + end + end + def self.configure_gem_version_promoter(definition, options) patch_level = patch_level_options(options) raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1 diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb index beeb2e4633..223db9419f 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -22,7 +22,10 @@ module Bundler Bundler::Fetcher.disable_endpoint = options["full-index"] update = options[:update] - update = { :gems => update, :lock_shared_dependencies => options[:conservative] } if update.is_a?(Array) + if update.is_a?(Array) # unlocking specific gems + Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update) + update = { :gems => update, :lock_shared_dependencies => options[:conservative] } + end definition = Bundler.definition(update) Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update] diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 8a7541c259..df7524f004 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -25,12 +25,7 @@ module Bundler raise GemfileLockNotFound, "This Bundle hasn't been installed yet. " \ "Run `bundle install` to update and install the bundled gems." end - # cycle through the requested gems, to make sure they exist - names = Bundler.locked_gems.specs.map(&:name) - gems.each do |g| - next if names.include?(g) - raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(g, names) - end + Bundler::CLI::Common.ensure_all_gems_in_lockfile!(gems) if groups.any? specs = Bundler.definition.specs_for groups |