summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-08-06 19:43:16 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-03 23:38:37 +0900
commit0775c239e111e7738a89cb3e44f585c6e1c158da (patch)
tree7e74c5c8c0b871199aea10bd4fdff19a92ebc89f /lib
parentcbd0de84f6325a66d9d97b17073252bc0e2bb512 (diff)
[rubygems/rubygems] Let `gem sources` be more clear about which sources it's displaying
https://github.com/rubygems/rubygems/commit/2afefa4a48
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/commands/sources_command.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index 976f4a4ea2..a86d8d5014 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -128,7 +128,7 @@ yourself to use your own gem server.
Without any arguments the sources lists your currently configured sources:
$ gem sources
- *** CURRENT SOURCES ***
+ *** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***
https://rubygems.org
@@ -164,10 +164,18 @@ To remove a source use the --remove argument:
end
def list # :nodoc:
- say "*** CURRENT SOURCES ***"
+ if configured_sources
+ header = "*** CURRENT SOURCES ***"
+ list = configured_sources
+ else
+ header = "*** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW ***"
+ list = Gem.sources
+ end
+
+ say header
say
- Gem.sources.each do |src|
+ list.each do |src|
say src
end
end
@@ -224,4 +232,10 @@ To remove a source use the --remove argument:
say "*** Unable to remove #{desc} source cache ***"
end
end
+
+ private
+
+ def configured_sources
+ Gem.configuration.sources
+ end
end