From 12ac0fa9396d08899cc3efdd7398f71b618ba9a0 Mon Sep 17 00:00:00 2001 From: Thomas McDonald Date: Thu, 4 Jul 2019 15:30:15 +0100 Subject: [PATCH] [rubygems/rubygems] Simplify host switching logic This block was a branch and variable heavy way of saying use the user-provided host if available, or fall-back to the default host if none of the other options match. IMO the resultant single-if condition is clearer in intentions https://github.com/rubygems/rubygems/commit/42dbb71cfa --- lib/rubygems/commands/push_command.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index fe8157e502..bdb92cbb42 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -52,23 +52,14 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo gem_name = get_one_gem_name default_gem_server, push_host = get_hosts_for(gem_name) - default_host = nil - user_defined_host = nil - - if @user_defined_host - user_defined_host = options[:host] - else - default_host = options[:host] - end - - @host = if user_defined_host - user_defined_host + @host = if @user_defined_host + options[:host] elsif default_gem_server default_gem_server elsif push_host push_host else - default_host + options[:host] end sign_in @host