Skip to content

Commit

Permalink
[rubygems/rubygems] Many major_deprecations supply :removed_message
Browse files Browse the repository at this point in the history
Generally the removed message is very similar, but often it needs to
specify that the feature has "been removed" instead of "will be
removed", or "been deprecated". And a few chunks of text needed more
substantial updates. And a number of them seemed to have been carefully
crafted to make sense in either context, so I left those alone.

rubygems/rubygems@8d42cf9104
  • Loading branch information
nevinera authored and matzbot committed Dec 1, 2023
1 parent 079dfa1 commit 73440e1
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 46 deletions.
48 changes: 24 additions & 24 deletions lib/bundler.rb
Expand Up @@ -346,13 +346,13 @@ def original_env

# @deprecated Use `unbundled_env` instead
def clean_env
Bundler::SharedHelpers.major_deprecation(
2,
message =
"`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`",
:print_caller_location => true
)

"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
removed_message =
"`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
unbundled_env
end

Expand Down Expand Up @@ -389,13 +389,13 @@ def with_original_env

# @deprecated Use `with_unbundled_env` instead
def with_clean_env
Bundler::SharedHelpers.major_deprecation(
2,
message =
"`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`",
:print_caller_location => true
)

"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
removed_message =
"`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
with_env(unbundled_env) { yield }
end

Expand All @@ -411,13 +411,13 @@ def original_system(*args)

# @deprecated Use `unbundled_system` instead
def clean_system(*args)
Bundler::SharedHelpers.major_deprecation(
2,
message =
"`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
"If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`",
:print_caller_location => true
)

"If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
removed_message =
"`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \
"If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
with_env(unbundled_env) { Kernel.system(*args) }
end

Expand All @@ -433,13 +433,13 @@ def original_exec(*args)

# @deprecated Use `unbundled_exec` instead
def clean_exec(*args)
Bundler::SharedHelpers.major_deprecation(
2,
message =
"`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
"If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`",
:print_caller_location => true
)

"If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
removed_message =
"`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \
"If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
with_env(unbundled_env) { Kernel.exec(*args) }
end

Expand Down
46 changes: 36 additions & 10 deletions lib/bundler/cli.rb
Expand Up @@ -190,7 +190,12 @@ def check
method_option "install", :type => :boolean, :banner =>
"Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems)
SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
if ARGV.include?("--install")
message = "The `--install` flag has been deprecated. `bundle install` is triggered by default."
removed_message = "The `--install` flag has been removed. `bundle install` is triggered by default."
SharedHelpers.major_deprecation(2, message, :removed_message => removed_message)
end

require_relative "cli/remove"
Remove.new(gems, options).run
end
Expand Down Expand Up @@ -324,7 +329,11 @@ def update(*gems)
method_option "outdated", :type => :boolean,
:banner => "Show verbose output including whether gems are outdated."
def show(gem_name = nil)
SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated")
if ARGV.include?("--outdated")
message = "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement"
removed_message = "the `--outdated` flag to `bundle show` was undocumented and has been removed without replacement"
SharedHelpers.major_deprecation(2, message, :removed_message => removed_message)
end
require_relative "cli/show"
Show.new(options, gem_name).run
end
Expand Down Expand Up @@ -462,11 +471,18 @@ def fund
def cache
print_remembered_flag_deprecation("--all", "cache_all", "true") if ARGV.include?("--all")

SharedHelpers.major_deprecation 2,
"The `--path` flag is deprecated because its semantics are unclear. " \
"Use `bundle config cache_path` to configure the path of your cache of gems, " \
"and `bundle config path` to configure the path where your gems are installed, " \
"and stop using this flag" if ARGV.include?("--path")
if ARGV.include?("--path")
message =
"The `--path` flag is deprecated because its semantics are unclear. " \
"Use `bundle config cache_path` to configure the path of your cache of gems, " \
"and `bundle config path` to configure the path where your gems are installed, " \
"and stop using this flag"
removed_message =
"The `--path` flag has been removed because its semantics were unclear. " \
"Use `bundle config cache_path` to configure the path of your cache of gems, " \
"and `bundle config path` to configure the path where your gems are installed."
SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
end

require_relative "cli/cache"
Cache.new(options).run
Expand All @@ -484,7 +500,9 @@ def cache
D
def exec(*args)
if ARGV.include?("--no-keep-file-descriptors")
SharedHelpers.major_deprecation(2, "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to")
message = "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to"
removed_message = "The `--no-keep-file-descriptors` has been removed. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to"
SharedHelpers.major_deprecation(2, message, :removed_message => removed_message)
end

require_relative "cli/exec"
Expand Down Expand Up @@ -763,7 +781,9 @@ def self.check_deprecated_ext_option(arguments)
# when deprecated version of `--ext` is called
# print out deprecation warning and pretend `--ext=c` was provided
if deprecated_ext_value?(arguments)
SharedHelpers.major_deprecation 2, "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used."
message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used."
removed_message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension."
SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
arguments[arguments.index("--ext")] = "--ext=c"
end
end
Expand Down Expand Up @@ -888,11 +908,17 @@ def flag_deprecation(name, flag_name, option)
end

def print_remembered_flag_deprecation(flag_name, option_name, option_value)
Bundler::SharedHelpers.major_deprecation 2,
message =
"The `#{flag_name}` flag is deprecated because it relies on being " \
"remembered across bundler invocations, which bundler will no longer " \
"do in future versions. Instead please use `bundle config set #{option_name} " \
"#{option_value}`, and stop using this flag"
removed_message =
"The `#{flag_name}` flag has been removed because it relied on being " \
"remembered across bundler invocations, which bundler will no longer " \
"do. Instead please use `bundle config set #{option_name} " \
"#{option_value}`, and stop using this flag"
Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
end
end
end
5 changes: 3 additions & 2 deletions lib/bundler/cli/config.rb
Expand Up @@ -25,8 +25,9 @@ def base(name = nil, *value)
["config", "get", ARGV[1]]
end

SharedHelpers.major_deprecation 3,
"Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
removed_message = "Using the `config` command without a subcommand [list, get, set, unset] is has been removed. Use `bundle #{new_args.join(" ")}` instead."
SharedHelpers.major_deprecation 3, message, :removed_message => removed_message

Base.new(options, name, value, self).run
end
Expand Down
5 changes: 3 additions & 2 deletions lib/bundler/cli/console.rb
Expand Up @@ -9,8 +9,9 @@ def initialize(options, group)
end

def run
Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
"by `bin/console` generated by `bundle gem <name>`"
message = "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
removed_message = "bundle console has been replaced by `bin/console` generated by `bundle gem <name>`"
Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message

group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
ARGV.clear
Expand Down
11 changes: 8 additions & 3 deletions lib/bundler/cli/gem.rb
Expand Up @@ -380,15 +380,20 @@ def ask_and_set_linter
def deprecated_rubocop_option
if !options[:rubocop].nil?
if options[:rubocop]
Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
Bundler::SharedHelpers.major_deprecation 2,
"--rubocop is deprecated, use --linter=rubocop",
:removed_message => "--rubocop has been removed, use --linter=rubocop"
"rubocop"
else
Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
Bundler::SharedHelpers.major_deprecation 2,
"--no-rubocop is deprecated, use --linter",
:removed_message => "--no-rubocop has been removed, use --linter"
false
end
elsif !Bundler.settings["gem.rubocop"].nil?
Bundler::SharedHelpers.major_deprecation 2,
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
:removed_message => "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
Bundler.settings["gem.rubocop"] ? "rubocop" : false
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/cli/install.rb
Expand Up @@ -51,7 +51,8 @@ def run

if options["binstubs"]
Bundler::SharedHelpers.major_deprecation 2,
"The --binstubs option will be removed in favor of `bundle binstubs --all`"
"The --binstubs option will be removed in favor of `bundle binstubs --all`",
:removed_message => "The --binstubs option have been removed in favor of `bundle binstubs --all`"
end

Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
Expand Down
19 changes: 15 additions & 4 deletions lib/bundler/dsl.rb
Expand Up @@ -427,9 +427,13 @@ def validate_keys(command, opts, valid_keys)
def normalize_source(source)
case source
when :gemcutter, :rubygems, :rubyforge
Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \
"requests are insecure.\nPlease change your source to 'https://" \
"rubygems.org' if possible, or 'http://rubygems.org' if not."
message =
"The source :#{source} is deprecated because HTTP requests are insecure.\n" \
"Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not."
removed_message =
"The source :#{source} is disallowed because HTTP requests are insecure.\n" \
"Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not."
Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
"http://rubygems.org"
when String
source
Expand Down Expand Up @@ -474,10 +478,17 @@ def multiple_global_source_warning
"should come from that source"
raise GemfileEvalError, msg
else
Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
message =
"Your Gemfile contains multiple global sources. " \
"Using `source` more than once without a block is a security risk, and " \
"may result in installing unexpected gems. To resolve this warning, use " \
"a block to indicate which gems should come from the secondary source."
removed_message =
"Your Gemfile contains multiple global sources. " \
"Using `source` more than once without a block is a security risk, and " \
"may result in installing unexpected gems. To resolve this error, use " \
"a block to indicate which gems should come from the secondary source."
Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
end
end

Expand Down

0 comments on commit 73440e1

Please sign in to comment.