summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-01 13:12:19 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-01 13:12:19 -0500
commitf23c0b13578c6fcd26bb234ec9bb01ada0989f26 (patch)
tree6fb015bb4069d1ce38e8248047aed64ffb92bbd0
parent5100bff1c5d02e11764d289089851daeeef9808b (diff)
downloadbundler-seg-lock-update-missing.tar.gz
[CLI::Common] Extract update lockfile checking logicseg-lock-update-missing
-rw-r--r--lib/bundler/cli/common.rb7
-rw-r--r--lib/bundler/cli/lock.rb7
-rw-r--r--lib/bundler/cli/update.rb7
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