Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Reword deprecation messages
Browse files Browse the repository at this point in the history
Including the version is confusing, in my opinion, because it's unclear
whether it refers to the future version of removal, or to the current
running version.
  • Loading branch information
deivid-rodriguez committed Feb 14, 2019
1 parent ecfc2db commit cb19287
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def major_deprecation(major_version, message)
bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version
require "bundler/errors"
raise DeprecatedError, "[REMOVED FROM #{major_version.succ}.0] #{message}"
raise DeprecatedError, "[REMOVED] #{message}"
end

return unless bundler_major_version >= major_version || prints_major_deprecations?
@major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
ui = Bundler.ui.is_a?(@major_deprecation_ui.class) ? Bundler.ui : @major_deprecation_ui
ui.warn("[DEPRECATED FOR #{major_version}.0] #{message}")
ui.warn("[DEPRECATED] #{message}")
end

def print_major_deprecations!
Expand Down
8 changes: 4 additions & 4 deletions spec/commands/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

it "prints deprecation", :bundler => "2" do
bundle "show rails"
expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`")
expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`")
end

it "prints path if gem exists in bundle (with --paths option)" do
Expand All @@ -42,7 +42,7 @@

it "prints deprecation when called with a gem and the --paths option", :bundler => "2" do
bundle "show rails --paths"
expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`")
expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`")
end

it "warns if path no longer exists on disk" do
Expand All @@ -61,7 +61,7 @@

it "prints deprecation when called with bundler", :bundler => "2" do
bundle "show bundler"
expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`")
expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`")
end
it "complains if gem not in bundle" do
bundle "show missing"
Expand All @@ -82,7 +82,7 @@
it "prints a deprecation when called with the --paths option", :bundler => 2 do
bundle "show --paths"

expect(err).to eq("[DEPRECATED FOR 2.0] use `bundle list` instead of `bundle show --paths`")
expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`")
end

it "prints summary of gems" do
Expand Down
12 changes: 6 additions & 6 deletions spec/install/redownload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@

it "shows a deprecation when single flag passed", :bundler => 2 do
bundle! "install --force"
expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "shows a deprecation when multiple flags passed", :bundler => 2 do
bundle! "install --no-color --force"
expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "does not show a deprecation when single flag passed", :bundler => "< 2" do
bundle! "install --force"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
bundle! "install --no-color --force"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end

Expand All @@ -89,12 +89,12 @@

it "does not show a deprecation when single flag passed" do
bundle! "install --redownload"
expect(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).not_to include "[DEPRECATED] 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(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end
8 changes: 4 additions & 4 deletions spec/runtime/with_unbundled_env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def build_bundler_context
code = "Bundler.clean_env"
bundle_exec_ruby! code.dump
expect(err).to include(
"[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
)
end
Expand All @@ -116,7 +116,7 @@ def build_bundler_context
code = "Bundler.clean_env"
bundle_exec_ruby! code.dump
expect(out).not_to include(
"[DEPRECATED FOR 2.0] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
)
end
Expand Down Expand Up @@ -157,7 +157,7 @@ def build_bundler_context
code = "Bundler.with_clean_env {}"
bundle_exec_ruby! code.dump
expect(err).to include(
"[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
)
end
Expand All @@ -166,7 +166,7 @@ def build_bundler_context
code = "Bundler.with_clean_env {}"
bundle_exec_ruby! code.dump
expect(out).not_to include(
"[DEPRECATED FOR 2.0] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def self.define_compound_matcher(matcher, preconditions, &declarations)
end
end

MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/
MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/

RSpec::Matchers.define :eq_err do |expected|
diffable
Expand Down
12 changes: 6 additions & 6 deletions spec/update/redownload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@
describe "with --force" do
it "shows a deprecation when single flag passed", :bundler => 2 do
bundle! "update rack --force"
expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "shows a deprecation when multiple flags passed", :bundler => 2 do
bundle! "update rack --no-color --force"
expect(err).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "does not show a deprecation when single flag passed", :bundler => "< 2" do
bundle! "update rack --force"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end

it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
bundle! "update rack --no-color --force"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(out).not_to include "[DEPRECATED] 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(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).not_to include "[DEPRECATED] 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(err).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end

0 comments on commit cb19287

Please sign in to comment.