diff options
author | Jenny Shen <jenny.shen@shopify.com> | 2022-09-16 08:48:38 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-09-29 17:56:34 +0900 |
commit | 1cbf0fd86356ccbac5556ab0f63ea8a4b08fd24d (patch) | |
tree | 594fd118edf2ddb0af882955521a1f048805515d /lib/rubygems | |
parent | 9948b8bfec08d18c2803dd1fced82a6c28967441 (diff) |
[rubygems/rubygems] Add error message when api response is a permanent redirect
https://github.com/rubygems/rubygems/commit/ccca30c77a
Co-authored-by: Nick Schwaderer <nick.schwaderer@shopify.com>
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index a785159196..1112498357 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -201,7 +201,8 @@ module Gem::GemcutterUtilities # block was given or shows the response body to the user. # # If the response was not successful, shows an error to the user including - # the +error_prefix+ and the response body. + # the +error_prefix+ and the response body. If the response was a permanent redirect, + # shows an error to the user including the redirect location. def with_response(response, error_prefix = nil) case response @@ -211,6 +212,13 @@ module Gem::GemcutterUtilities else say clean_text(response.body) end + when Net::HTTPPermanentRedirect, Net::HTTPRedirection then + message = "The request has redirected permanently to #{Gem::Uri.parse(response['location']).origin}. " \ + "Please check your defined push host." + message = "#{error_prefix}: #{message}" if error_prefix + + say clean_text(message) + terminate_interaction(ERROR_CODE) else message = response.body message = "#{error_prefix}: #{message}" if error_prefix |