summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-08-13 11:53:45 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-03 23:38:37 +0900
commitcc1770b968257ca6d6ec5a49b6ef54d4a4853974 (patch)
treedf42c800e892bdecbd6fa1f6325c4211dc5d1125
parent2e65f4ac3b1d69e7bd9e3e65a696e7f234ec9527 (diff)
[rubygems/rubygems] Introduce `SharedHelpers.feature_removed!`
To directly raise regardless of version. https://github.com/rubygems/rubygems/commit/38fb97cffa
-rw-r--r--lib/bundler/errors.rb1
-rw-r--r--lib/bundler/shared_helpers.rb10
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb6
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
index 4d1bface51..28da892d31 100644
--- a/lib/bundler/errors.rb
+++ b/lib/bundler/errors.rb
@@ -25,6 +25,7 @@ module Bundler
class GemNotFound < BundlerError; status_code(7); end
class InstallHookError < BundlerError; status_code(8); end
+ class RemovedError < BundlerError; status_code(9); end
class GemfileNotFound < BundlerError; status_code(10); end
class GitError < BundlerError; status_code(11); end
class DeprecatedError < BundlerError; status_code(12); end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index b020c67143..41b7128d36 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -137,14 +137,20 @@ module Bundler
feature_flag = Bundler.feature_flag
if feature_flag.removed_major?(major_version)
- require_relative "errors"
- raise DeprecatedError, "[REMOVED] #{removed_message || message}"
+ feature_removed!(removed_message || message)
end
return unless feature_flag.deprecated_major?(major_version) && prints_major_deprecations?
Bundler.ui.warn("[DEPRECATED] #{message}")
end
+ def feature_removed!(message)
+ require_relative "../bundler"
+
+ require_relative "errors"
+ raise RemovedError, "[REMOVED] #{message}"
+ end
+
def print_major_deprecations!
multiple_gemfiles = search_up(".") do |dir|
gemfiles = gemfile_names.select {|gf| File.file? File.expand_path(gf, dir) }
diff --git a/spec/bundler/bundler/shared_helpers_spec.rb b/spec/bundler/bundler/shared_helpers_spec.rb
index 5045b86e4e..5b3a9c17a7 100644
--- a/spec/bundler/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/bundler/shared_helpers_spec.rb
@@ -538,11 +538,11 @@ RSpec.describe Bundler::SharedHelpers do
it "raises the appropriate errors when _past_ the deprecated major version" do
expect { subject.major_deprecation(36, "Message") }.
- to raise_error(Bundler::DeprecatedError, "[REMOVED] Message")
+ to raise_error(Bundler::RemovedError, "[REMOVED] Message")
expect { subject.major_deprecation(36, "Message", removed_message: "Removal") }.
- to raise_error(Bundler::DeprecatedError, "[REMOVED] Removal")
+ to raise_error(Bundler::RemovedError, "[REMOVED] Removal")
expect { subject.major_deprecation(35, "Message", removed_message: "Removal", print_caller_location: true) }.
- to raise_error(Bundler::DeprecatedError, "[REMOVED] Removal")
+ to raise_error(Bundler::RemovedError, "[REMOVED] Removal")
end
end
end