diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-01 13:12:19 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-01 13:12:19 -0500 |
commit | f23c0b13578c6fcd26bb234ec9bb01ada0989f26 (patch) | |
tree | 6fb015bb4069d1ce38e8248047aed64ffb92bbd0 | |
parent | 5100bff1c5d02e11764d289089851daeeef9808b (diff) | |
download | bundler-seg-lock-update-missing.tar.gz |
[CLI::Common] Extract update lockfile checking logicseg-lock-update-missing
-rw-r--r-- | lib/bundler/cli/common.rb | 7 | ||||
-rw-r--r-- | lib/bundler/cli/lock.rb | 7 | ||||
-rw-r--r-- | lib/bundler/cli/update.rb | 7 |
3 files changed, 9 insertions, 12 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 8b14f2c7d3..223db9419f 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -23,12 +23,7 @@ module Bundler update = options[:update] if update.is_a?(Array) # unlocking specific gems - # cycle through the requested gems, to make sure they exist - names = Bundler.locked_gems.specs.map(&:name) - update.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!(update) update = { :gems => update, :lock_shared_dependencies => options[:conservative] } end definition = Bundler.definition(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 |