summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-14 10:10:36 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-14 16:09:40 -0500
commite9cf5df06df18255ff322ba770d19abc4a76db75 (patch)
tree052807f4c70ec157b8a007c6a1aff5a992808d05
parentd34a2a79fcb21ef6feca54f0fd97369125f53f1c (diff)
downloadbundler-e9cf5df06df18255ff322ba770d19abc4a76db75.tar.gz
Add `—all` flag to `bundle update`
And require it on 2+
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/update.rb13
-rw-r--r--lib/bundler/feature_flag.rb5
-rw-r--r--lib/bundler/settings.rb1
-rw-r--r--man/bundle-config.ronn3
-rw-r--r--spec/commands/update_spec.rb22
6 files changed, 43 insertions, 3 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 10287d3ac7..7e3aa27ef3 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -221,6 +221,8 @@ module Bundler
"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 allow shared dependencies to be updated."
+ method_option "all", :type => :boolean, :banner =>
+ "Update everything."
def update(*gems)
require "bundler/cli/update"
Update.new(options, gems).run
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index df7524f004..9e4543668e 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -17,7 +17,18 @@ module Bundler
sources = Array(options[:source])
groups = Array(options[:group]).map(&:to_sym)
- if gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
+ full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler]
+
+ if full_update && !options[:all]
+ if Bundler.feature_flag.update_requires_all_flag?
+ raise InvalidOption, "To update everything, pass the `--all` flag."
+ end
+ SharedHelpers.major_deprecation "Pass --all to `bundle update` to update everything"
+ elsif !full_update && options[:all]
+ raise InvalidOption, "Cannot specify --all along with specific options."
+ end
+
+ if full_update
# We're doing a full update
Bundler.definition(true)
else
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 3a4353f2af..f472ba2b7b 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -15,10 +15,11 @@ module Bundler
(1..10).each {|v| define_method("bundler_#{v}_mode?") { major_version >= v } }
settings_flag(:allow_offline_install) { bundler_2_mode? }
- settings_flag(:only_update_to_newer_versions) { bundler_2_mode? }
- settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:error_on_stderr) { bundler_2_mode? }
settings_flag(:init_gems_rb) { bundler_2_mode? }
+ settings_flag(:only_update_to_newer_versions) { bundler_2_mode? }
+ settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
+ settings_flag(:update_requires_all_flag) { bundler_2_mode? }
def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version)
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 5370b4c3d5..34747cbed7 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -29,6 +29,7 @@ module Bundler
only_update_to_newer_versions
plugins
silence_root_warning
+ update_requires_all_flag
].freeze
NUMBER_KEYS = %w[
diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn
index 18773017f8..d387350f8b 100644
--- a/man/bundle-config.ronn
+++ b/man/bundle-config.ronn
@@ -226,6 +226,9 @@ learn more about their operation in [bundle install(1)][bundle-install].
Print Bundler errors to stderr
* `init_gems_rb` (`BUNDLE_NEW_GEMFILE_NAME`)
generate a new gems.rb on `bundle init` instead of the `Gemfile`
+* `update_requires_all_flag` (`BUNDLE_UPDATE_REQUIRES_ALL_FLAG`)
+ Require passing `--all` to `bundle update` when everything should be updated,
+ and disallow passing no options to `bundle update`.
In general, you should set these settings per-application by using the applicable
flag to the [bundle install(1)][bundle-install] or [bundle package(1)][bundle-package] command.
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index b278036a12..b0a55ab930 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -34,6 +34,28 @@ RSpec.describe "bundle update" do
end
end
+ context "when update_requires_all_flag is set" do
+ before { bundle! "config update_requires_all_flag true" }
+
+ it "errors when passed nothing" do
+ install_gemfile! ""
+ bundle :update
+ expect(out).to eq("To update everything, pass the `--all` flag.")
+ end
+
+ it "errors when passed --all and another option" do
+ install_gemfile! ""
+ bundle "update --all foo"
+ expect(out).to eq("Cannot specify --all along with specific options.")
+ end
+
+ it "updates everything when passed --all" do
+ install_gemfile! ""
+ bundle "update --all"
+ expect(out).to include("Bundle updated!")
+ end
+ end
+
describe "--quiet argument" do
it "hides UI messages" do
bundle "update --quiet"