diff options
author | Bundlerbot <bot@bundler.io> | 2019-09-27 05:36:29 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2019-09-27 05:36:29 +0000 |
commit | e719a58b26e2f85c885a950d90c8d4a0f7339c0f (patch) | |
tree | ada5f1a7f642398bcbfbe88164de972a0a8fb871 /lib/bundler | |
parent | 1da170e369c67d789b902fb26465f89ff573f562 (diff) | |
parent | 751641649580f544e92311e1aafeea8e158a36e1 (diff) | |
download | bundler-e719a58b26e2f85c885a950d90c8d4a0f7339c0f.tar.gz |
Merge #7361
7361: Add caller information to some deprecation messages r=indirect a=deivid-rodriguez
### What was the end-user problem that led to this PR?
The problem was that some deprecations mention usage of deprecated methods, but include no information about where the deprecated method is being called.
### What was your diagnosis of the problem?
My diagnosis was that we should include this information with this kind of deprecation messages, to make migration easier.
### What is your fix for the problem, implemented in this PR?
My fix is to add an optional argument to the `major_deprecation` method, to print the location of the deprecated caller.
### Why did you choose this fix out of the possible options?
I chose this fix because it required little code changes.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/shared_helpers.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index e6e2b79344..dc44f8345c 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -124,7 +124,12 @@ module Bundler namespace.const_get(constant_name) end - def major_deprecation(major_version, message) + def major_deprecation(major_version, message, print_caller_location: false) + if print_caller_location + caller_location = caller_locations(2, 2).first + message = "#{message} (called at #{caller_location.path}:#{caller_location.lineno})" + end + bundler_major_version = Bundler.bundler_major_version if bundler_major_version > major_version require_relative "errors" |