summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2018-09-24 11:00:55 +0000
committerColby Swandale <me@colby.fyi>2018-10-09 23:00:20 +1100
commit3bc9b0d9b4dca2c2455ce42d7e7f2af70d4f488d (patch)
tree5d6cc36bf662b5f5daf0204d34c88d9454cfa69a
parent17572f0e883617ae9b222a856f151cd8f0cd1ed9 (diff)
downloadbundler-3bc9b0d9b4dca2c2455ce42d7e7f2af70d4f488d.tar.gz
Merge #6702
6702: Better `--force` to `--redownload` transition r=indirect a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was. that, while trying to run `bundle install --force` today, I was getting the error `unknown switch --force` error, and I was not sure what was causing it and what I needed to do to fix it. Also, running `bundle install --help` would show `--force` as a supported option, so that would make things even more confusing. ### What was your diagnosis of the problem? My diagnosis was that: * A lot of removal/renaming of options in bundler 2 are artificially linked to the `forget_cli_options` switch. To me, those changes even though they are related (stopping rememebering cli options prompted us to actually remove some unnecessary ones), they are independent, so it's not straighforward to find out that it's the `forget_cli_options` setting causing this rename to be in place. * We should show a helpful deprecation message instead of a hard error, so the transition is easier for users. * We should update the commands help to document newer instead of deprecated options. * The `bundle update` command has an equivalent `--force` option that should be renamed too for sanity. ### What is your fix for the problem, implemented in this PR? My fix to the above problems is to: * Always keep the `--force` alias, independently of whether the `forget_cli_options` is set or not. * Show a deprecation message when `--force` is used in bundler 2, but still keep it working as before. * Update the commands help to use `--redownload`. * Make the equivalent changes to the `bundle update` ### Why did you choose this fix out of the possible options? I chose this fix because it seems like the more user friendly way going forward in my opinion. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> (cherry picked from commit 16ebc8105b333e055e44711df59e0d42e88963ce)
-rw-r--r--lib/bundler/cli.rb7
-rw-r--r--man/bundle-install.ronn4
-rw-r--r--man/bundle-update.ronn4
-rw-r--r--spec/install/force_spec.rb62
-rw-r--r--spec/install/redownload_spec.rb90
-rw-r--r--spec/update/redownload_spec.rb34
6 files changed, 132 insertions, 69 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index dd4301959a..ce15ef9648 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -206,8 +206,7 @@ module Bundler
"Do not attempt to fetch gems remotely and use the gem cache instead"
deprecated_option "no-cache", :type => :boolean, :banner =>
"Don't update the existing gem cache."
- method_option "redownload", :type => :boolean, :aliases =>
- [Bundler.feature_flag.forget_cli_options? ? nil : "--force"].compact, :banner =>
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
"Force downloading every gem."
deprecated_option "no-prune", :type => :boolean, :banner =>
"Don't remove stale gems from the cache."
@@ -230,6 +229,7 @@ module Bundler
"Include gems that are part of the specified named group."
map "i" => "install"
def install
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require "bundler/cli/install"
Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run
@@ -256,7 +256,7 @@ module Bundler
"Only output warnings and errors."
method_option "source", :type => :array, :banner =>
"Update a specific source (and all gems associated with it)"
- method_option "force", :type => :boolean, :banner =>
+ method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
"Force downloading every gem."
method_option "ruby", :type => :boolean, :banner =>
"Update ruby specified in Gemfile.lock"
@@ -275,6 +275,7 @@ module Bundler
method_option "all", :type => :boolean, :banner =>
"Update everything."
def update(*gems)
+ SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require "bundler/cli/update"
Update.new(options, gems).run
end
diff --git a/man/bundle-install.ronn b/man/bundle-install.ronn
index 4841bc0abe..ca5e83192f 100644
--- a/man/bundle-install.ronn
+++ b/man/bundle-install.ronn
@@ -6,7 +6,6 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
`bundle install` [--binstubs[=DIRECTORY]]
[--clean]
[--deployment]
- [--force]
[--frozen]
[--full-index]
[--gemfile=GEMFILE]
@@ -16,6 +15,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
[--no-prune]
[--path PATH]
[--quiet]
+ [--redownload]
[--retry=NUMBER]
[--shebang]
[--standalone[=GROUP[ GROUP...]]]
@@ -64,7 +64,7 @@ time `bundle install` is run, use `bundle config` (see bundle-config(1)).
production or CI use. Please check carefully if you want to have this option
enabled in your development environment.
-* `--force`:
+* `--redownload`:
Force download every gem, even if the required versions are already available
locally.
diff --git a/man/bundle-update.ronn b/man/bundle-update.ronn
index 2ad678f424..397fecadcb 100644
--- a/man/bundle-update.ronn
+++ b/man/bundle-update.ronn
@@ -12,8 +12,8 @@ bundle-update(1) -- Update your gems to the latest available versions
[--full-index]
[--jobs=JOBS]
[--quiet]
- [--force]
[--patch|--minor|--major]
+ [--redownload]
[--strict]
[--conservative]
@@ -64,7 +64,7 @@ gem.
* `--quiet`:
Only output warnings and errors.
-* `--force`:
+* `--redownload`:
Force downloading every gem.
* `--patch`:
diff --git a/spec/install/force_spec.rb b/spec/install/force_spec.rb
deleted file mode 100644
index 52fa4f0d61..0000000000
--- a/spec/install/force_spec.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle install" do
- %w[force redownload].each do |flag|
- describe_opts = {}
- describe_opts[:bundler] = "< 2" if flag == "force"
- describe "with --#{flag}", describe_opts do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
- end
-
- it "re-installs installed gems" do
- rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
-
- bundle! :install
- rack_lib.open("w") {|f| f.write("blah blah blah") }
- bundle! :install, flag => true
-
- expect(out).to include "Installing rack 1.0.0"
- expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "works on first bundle install" do
- bundle! :install, flag => true
-
- expect(out).to include "Installing rack 1.0.0"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- context "with a git gem" do
- let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) }
-
- before do
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
- end
-
- it "re-installs installed gems" do
- foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb")
-
- bundle! :install
- foo_lib.open("w") {|f| f.write("blah blah blah") }
- bundle! :install, flag => true
-
- expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works on first bundle install" do
- bundle! :install, flag => true
-
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
- end
- end
-end
diff --git a/spec/install/redownload_spec.rb b/spec/install/redownload_spec.rb
new file mode 100644
index 0000000000..1225c839c4
--- /dev/null
+++ b/spec/install/redownload_spec.rb
@@ -0,0 +1,90 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundle install", :bundler => "2" do
+ before :each do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ shared_examples_for "an option to force redownloading gems" do
+ it "re-installs installed gems" do
+ rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
+
+ bundle! :install
+ rack_lib.open("w") {|f| f.write("blah blah blah") }
+ bundle! :install, flag => true
+
+ expect(out).to include "Installing rack 1.0.0"
+ expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "works on first bundle install" do
+ bundle! :install, flag => true
+
+ expect(out).to include "Installing rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ context "with a git gem" do
+ let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) }
+
+ before do
+ gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+ end
+
+ it "re-installs installed gems" do
+ foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb")
+
+ bundle! :install
+ foo_lib.open("w") {|f| f.write("blah blah blah") }
+ bundle! :install, flag => true
+
+ expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
+ expect(the_bundle).to include_gems "foo 1.0"
+ end
+
+ it "works on first bundle install" do
+ bundle! :install, flag => true
+
+ expect(the_bundle).to include_gems "foo 1.0"
+ end
+ end
+ end
+
+ describe "with --force" do
+ it_behaves_like "an option to force redownloading gems" do
+ let(:flag) { "force" }
+ end
+
+ it "shows a deprecation when single flag passed" do
+ bundle! "install --force"
+ expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+
+ it "shows a deprecation when multiple flags passed" do
+ bundle! "install --no-color --force"
+ expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+ end
+
+ describe "with --redownload" do
+ it_behaves_like "an option to force redownloading gems" do
+ let(:flag) { "redownload" }
+ end
+
+ it "does not show a deprecation when single flag passed" do
+ bundle! "install --redownload"
+ expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+
+ it "does not show a deprecation when single multiple flags passed" do
+ bundle! "install --no-color --redownload"
+ expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+ end
+end
diff --git a/spec/update/redownload_spec.rb b/spec/update/redownload_spec.rb
new file mode 100644
index 0000000000..8c716664e2
--- /dev/null
+++ b/spec/update/redownload_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundle update", :bundler => "2" do
+ before :each do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ describe "with --force" do
+ it "shows a deprecation when single flag passed" do
+ bundle! "update rack --force"
+ expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+
+ it "shows a deprecation when multiple flags passed" do
+ bundle! "update rack --no-color --force"
+ expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+ end
+
+ describe "with --redownload" do
+ it "does not show a deprecation when single flag passed" do
+ bundle! "update rack --redownload"
+ expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+
+ it "does not show a deprecation when single multiple flags passed" do
+ bundle! "update rack --no-color --redownload"
+ expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ end
+ end
+end