summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorchrismo <chrismo@clabs.org>2016-09-13 19:09:53 -0500
committerchrismo <chrismo@clabs.org>2016-10-21 00:26:27 -0500
commitad80a9238f4e98e73a9978ca747c4d24fddc7767 (patch)
tree1ee90f46a5a76424206bb63790479dbf711994cf /lib
parent7327dc59476c79547170d3ef8162f24b3aea385f (diff)
downloadbundler-ad80a9238f4e98e73a9978ca747c4d24fddc7767.tar.gz
Add bundle install conservative updating to update
In the discussion on new 1.13 Conservative Bundle Updates (see https://github.com/bundler/bundler-features/issues/122), some users would like to have the same Conservative Updating (see http://bundler.io/v1.12/man/bundle-install.1.html#CONSERVATIVE-UPDATING) behavior available in `bundle install` when a declared dependency is altered in the Gemfile, also available in the `bundle update` command. This adds a new option called `--conservative` to both `bundle update` and `bundle lock`. The option only applies on `bundle lock` if the `--update` option is in use. The internal flag is more descriptive as to what actually takes place: It locks any shared dependencies from the gem(s) being updated. This also promotes the previously added patch level options to being shown in command-line help, anticipating a 1.14 release, to make these public and documented.
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb28
-rw-r--r--lib/bundler/cli/lock.rb2
-rw-r--r--lib/bundler/cli/update.rb3
-rw-r--r--lib/bundler/definition.rb7
4 files changed, 24 insertions, 16 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index f92ecb1c33..6ee9adf431 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -215,14 +215,16 @@ module Bundler
"Update ruby specified in Gemfile.lock"
method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
"Update the locked version of bundler"
- method_option "patch", :type => :boolean, :hide => true, :banner =>
+ method_option "patch", :type => :boolean, :banner =>
"Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :hide => true, :banner =>
+ method_option "minor", :type => :boolean, :banner =>
"Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :hide => true, :banner =>
+ method_option "major", :type => :boolean, :banner =>
"Prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :hide => true, :banner =>
+ method_option "strict", :type => :boolean, :banner =>
"Do not allow any gem to be updated past latest --patch/--minor/--major"
+ method_option "conservative", :type => :boolean, :banner =>
+ "Use bundle install conservative update behavior and do not allowed shared dependencies to be updated."
def update(*gems)
require "bundler/cli/update"
Update.new(options, gems).run
@@ -459,14 +461,16 @@ module Bundler
"add a new platform to the lockfile"
method_option "remove-platform", :type => :array, :default => [], :banner =>
"remove a platform from the lockfile"
- method_option "patch", :type => :boolean, :hide => true, :banner =>
- "Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :hide => true, :banner =>
- "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :hide => true, :banner =>
- "Prefer updating to next major version (default)"
- method_option "strict", :type => :boolean, :hide => true, :banner =>
- "Do not allow any gem to be updated past latest --patch/--minor/--major"
+ method_option "patch", :type => :boolean, :banner =>
+ "If updating, prefer updating only to next patch version"
+ method_option "minor", :type => :boolean, :banner =>
+ "If updating, prefer updating only to next minor version"
+ method_option "major", :type => :boolean, :banner =>
+ "If updating, prefer updating to next major version (default)"
+ method_option "strict", :type => :boolean, :banner =>
+ "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", :type => :boolean, :banner =>
+ "If updating, use bundle install conservative update behavior and do not allowed shared dependencies to be updated."
def lock
require "bundler/cli/lock"
Lock.new(options).run
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index eb47c9efb0..225a07aa97 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -22,7 +22,7 @@ module Bundler
Bundler::Fetcher.disable_endpoint = options["full-index"]
update = options[:update]
- update = { :gems => update } if update.is_a?(Array)
+ update = { :gems => update, :lock_shared_dependencies => options[:conservative] } if update.is_a?(Array)
definition = Bundler.definition(update)
Bundler::CLI::Common.config_gem_version_promoter(Bundler.definition, options) if options[:update]
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index 51de98bf34..585fe38e17 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -37,7 +37,8 @@ module Bundler
gems.concat(specs.map(&:name))
end
- Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby])
+ Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
+ :lock_shared_dependencies => options[:conservative])
end
Bundler::CLI::Common.config_gem_version_promoter(Bundler.definition, options)
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 8a6bf0d17c..8141e6e54e 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -105,8 +105,11 @@ module Bundler
add_current_platform unless Bundler.settings[:frozen]
@path_changes = converge_paths
- eager_unlock = expand_dependencies(@unlock[:gems])
- @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
+
+ unless @unlock[:lock_shared_dependencies]
+ eager_unlock = expand_dependencies(@unlock[:gems])
+ @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
+ end
@gem_version_promoter = create_gem_version_promoter