summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-01-29 09:16:41 +0000
committerBundlerbot <bot@bundler.io>2019-01-29 09:16:41 +0000
commit66e4215dbf87fedf2fdff3532a0742340c4e02f2 (patch)
tree0fa2a16ecadcb4bbd60a29e4e489488b66142a44
parent2b8015c2aa696209526f5747d09ee41f48553d46 (diff)
parent36b198e840e5c6ca7deee69da03e1b84b0d387fa (diff)
downloadbundler-66e4215dbf87fedf2fdff3532a0742340c4e02f2.tar.gz
Merge #6931
6931: Add patch option in bundle config r=greysteil a=ankitkataria ### What was the end-user problem that led to this PR? Issue #5994 ### What was your diagnosis of the problem? As mentioned by @indirect I added a `patch` option in the bundler config, which by default is false. If set to true, patch level update are preferred if no update levels are specified. ### What is your fix for the problem, implemented in this PR? A patch level config option which can be opted into. Co-authored-by: Ankit Kataria <ankitkataria28@gmail.com>
-rw-r--r--lib/bundler/cli/common.rb2
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--man/bundle-config.ronn2
-rw-r--r--spec/commands/update_spec.rb9
4 files changed, 15 insertions, 0 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index 09a1753337..f22ef6ab71 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -80,7 +80,9 @@ module Bundler
def self.configure_gem_version_promoter(definition, options)
patch_level = patch_level_options(options)
+ patch_level << :patch if patch_level.empty? && Bundler.settings[:prefer_patch]
raise InvalidOption, "Provide only one of the following options: #{patch_level.join(", ")}" unless patch_level.length <= 1
+
definition.gem_version_promoter.tap do |gvp|
gvp.level = patch_level.first || :major
gvp.strict = options[:strict] || options["update-strict"] || options["filter-strict"]
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index fe68d510ff..e0b6facecb 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -49,6 +49,7 @@ module Bundler
path.system
plugins
prefer_gems_rb
+ prefer_patch
print_only_version_number
setup_makes_kernel_gem_public
silence_root_warning
@@ -76,6 +77,7 @@ module Bundler
DEFAULT_CONFIG = {
:disable_version_check => true,
+ :prefer_patch => false,
:redirect => 5,
:retry => 3,
:timeout => 10,
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index 379b778348..81e0aa303c 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -233,6 +233,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
Enable Bundler's experimental plugin system.
* `prefer_gems_rb` (`BUNDLE_PREFER_GEMS_RB`)
Prefer `gems.rb` to `Gemfile` when Bundler is searching for a Gemfile.
+* `prefer_patch` (BUNDLE_PREFER_PATCH):
+ Prefer updating only to next patch version during updates. Makes `bundle update` calls equivalent to `bundler update --patch`.
* `print_only_version_number` (`BUNDLE_PRINT_ONLY_VERSION_NUMBER`)
Print only version number from `bundler --version`.
* `redirect` (`BUNDLE_REDIRECT`):
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 6f29032dd2..d2cdd5a68b 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -809,6 +809,15 @@ RSpec.describe "bundle update conservative" do
G
end
+ context "with patch set as default update level in config" do
+ it "should do a patch level update" do
+ bundle! "config --local prefer_patch true"
+ bundle! "update foo"
+
+ expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
+ end
+ end
+
context "patch preferred" do
it "single gem updates dependent gem to minor" do
bundle! "update --patch foo"