aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/ruby-rubygems-2612-ruby24.patch
blob: 8ee32c0c6e7e06383c21b531c88d6c78dc779b64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
diff --git lib/rubygems.rb lib/rubygems.rb
index 5cd1a4c47a..bc5bf9b4c2 100644
--- ruby-2.4.1/lib/rubygems.rb
+++ ruby-2.4.1/lib/rubygems.rb
@@ -10,7 +10,7 @@
 require 'thread'
 
 module Gem
-  VERSION = "2.6.11"
+  VERSION = "2.6.12"
 end
 
 # Must be first since it unloads the prelude from 1.9.2
@@ -234,6 +234,7 @@ def self.needs
 
   def self.finish_resolve(request_set=Gem::RequestSet.new)
     request_set.import Gem::Specification.unresolved_deps.values
+    request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
 
     request_set.resolve_current.each do |s|
       s.full_spec.activate
diff --git lib/rubygems/commands/open_command.rb lib/rubygems/commands/open_command.rb
index a89b7421e3..059635e835 100644
--- ruby-2.4.1/lib/rubygems/commands/open_command.rb
+++ ruby-2.4.1/lib/rubygems/commands/open_command.rb
@@ -72,7 +72,7 @@ def open_editor path
   end
 
   def spec_for name
-    spec = Gem::Specification.find_all_by_name(name, @version).last
+    spec = Gem::Specification.find_all_by_name(name, @version).first
 
     return spec if spec
 
diff --git lib/rubygems/commands/query_command.rb lib/rubygems/commands/query_command.rb
index f25d120b88..70f8127292 100644
--- ruby-2.4.1/lib/rubygems/commands/query_command.rb
+++ ruby-2.4.1/lib/rubygems/commands/query_command.rb
@@ -86,7 +86,7 @@ def execute
       name = Array(options[:name])
     else
       args = options[:args].to_a
-      name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
+      name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
     end
 
     prerelease = options[:prerelease]
diff --git lib/rubygems/commands/sources_command.rb lib/rubygems/commands/sources_command.rb
index 9832afd214..7e46963a4c 100644
--- ruby-2.4.1/lib/rubygems/commands/sources_command.rb
+++ ruby-2.4.1/lib/rubygems/commands/sources_command.rb
@@ -44,7 +44,7 @@ def add_source source_uri # :nodoc:
     source = Gem::Source.new source_uri
 
     begin
-      if Gem.sources.include? source_uri then
+      if Gem.sources.include? source then
         say "source #{source_uri} already present in the cache"
       else
         source.load_specs :released
diff --git lib/rubygems/dependency_list.rb lib/rubygems/dependency_list.rb
index 35fe7c4c1a..d8314eaf60 100644
--- ruby-2.4.1/lib/rubygems/dependency_list.rb
+++ ruby-2.4.1/lib/rubygems/dependency_list.rb
@@ -104,7 +104,7 @@ def find_name(full_name)
   end
 
   def inspect # :nodoc:
-    "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
+    "%s %p>" % [super[0..-2], map { |s| s.full_name }]
   end
 
   ##
diff --git lib/rubygems/installer.rb lib/rubygems/installer.rb
index f4d3e728de..967543c2d1 100644
--- ruby-2.4.1/lib/rubygems/installer.rb
+++ ruby-2.4.1/lib/rubygems/installer.rb
@@ -214,7 +214,7 @@ def check_executable_overwrite filename # :nodoc:
 
       ruby_executable = true
       existing = io.read.slice(%r{
-          ^(
+          ^\s*(
             gem \s |
             load \s Gem\.bin_path\( |
             load \s Gem\.activate_bin_path\(
@@ -701,6 +701,8 @@ def verify_gem_home(unpack = false) # :nodoc:
   # Return the text for an application file.
 
   def app_script_text(bin_file_name)
+    # note that the `load` lines cannot be indented, as old RG versions match
+    # against the beginning of the line
     return <<-TEXT
 #{shebang bin_file_name}
 #
@@ -723,7 +725,12 @@ def app_script_text(bin_file_name)
   end
 end
 
+if Gem.respond_to?(:activate_bin_path)
 load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
+else
+gem #{spec.name.dump}, version
+load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
+end
 TEXT
   end
 
diff --git lib/rubygems/platform.rb lib/rubygems/platform.rb
index d22d91ae54..2dd9ed5782 100644
--- ruby-2.4.1/lib/rubygems/platform.rb
+++ ruby-2.4.1/lib/rubygems/platform.rb
@@ -112,7 +112,7 @@ def initialize(arch)
   end
 
   def inspect
-    "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
+    "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a]
   end
 
   def to_a
diff --git lib/rubygems/security.rb lib/rubygems/security.rb
index 119d6d56f7..6963ca156f 100644
--- ruby-2.4.1/lib/rubygems/security.rb
+++ ruby-2.4.1/lib/rubygems/security.rb
@@ -455,7 +455,7 @@ def self.create_cert_self_signed subject, key, age = ONE_YEAR,
 
   ##
   # Creates a new key pair of the specified +length+ and +algorithm+.  The
-  # default is a 2048 bit RSA key.
+  # default is a 3072 bit RSA key.
 
   def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM
     algorithm.new length
diff --git lib/rubygems/server.rb lib/rubygems/server.rb
index 81df0e608e..df4eb566d3 100644
--- ruby-2.4.1/lib/rubygems/server.rb
+++ ruby-2.4.1/lib/rubygems/server.rb
@@ -657,7 +657,7 @@ def root(req, res)
       "only_one_executable" => true,
       "full_name" => "rubygems-#{Gem::VERSION}",
       "has_deps" => false,
-      "homepage" => "http://docs.rubygems.org/",
+      "homepage" => "http://guides.rubygems.org/",
       "name" => 'rubygems',
       "ri_installed" => true,
       "summary" => "RubyGems itself",
diff --git lib/rubygems/specification.rb lib/rubygems/specification.rb
index a2f289d162..500f0af768 100644
--- ruby-2.4.1/lib/rubygems/specification.rb
+++ ruby-2.4.1/lib/rubygems/specification.rb
@@ -2105,7 +2105,7 @@ def inspect # :nodoc:
     if $DEBUG
       super
     else
-      "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>"
+      "#{super[0..-2]} #{full_name}>"
     end
   end
 
diff --git lib/rubygems/test_case.rb lib/rubygems/test_case.rb
index 86b68e1efb..4e48f1eb4c 100644
--- ruby-2.4.1/lib/rubygems/test_case.rb
+++ ruby-2.4.1/lib/rubygems/test_case.rb
@@ -484,7 +484,7 @@ def git_gem name = 'a', version = 1
 
       system @git, 'add', gemspec
       system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet'
-      head = Gem::Util.popen('git', 'rev-parse', 'master').strip
+      head = Gem::Util.popen(@git, 'rev-parse', 'master').strip
     end
 
     return name, git_spec.version, directory, head
@@ -1498,6 +1498,8 @@ def self.key_path key_name
 begin
   gem 'rdoc'
   require 'rdoc'
+
+  require 'rubygems/rdoc'
 rescue LoadError, Gem::LoadError
 end
 
@@ -1514,3 +1516,4 @@ def self.key_path key_name
 pid = $$
 END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
 Gem.clear_paths
+Gem.loaded_specs.clear
diff --git test/rubygems/test_gem.rb test/rubygems/test_gem.rb
index a605f9cdfe..62b36dfd41 100644
--- ruby-2.4.1/test/rubygems/test_gem.rb
+++ ruby-2.4.1/test/rubygems/test_gem.rb
@@ -75,6 +75,29 @@ def test_self_finish_resolve_wtf
     end
   end
 
+  def test_self_finish_resolve_respects_loaded_specs
+    save_loaded_features do
+      a1 = new_spec "a", "1", "b" => "> 0"
+      b1 = new_spec "b", "1", "c" => ">= 1"
+      b2 = new_spec "b", "2", "c" => ">= 2"
+      c1 = new_spec "c", "1"
+      c2 = new_spec "c", "2"
+
+      install_specs c1, c2, b1, b2, a1
+
+      a1.activate
+      c1.activate
+
+      assert_equal %w(a-1 c-1), loaded_spec_names
+      assert_equal ["b (> 0)"], unresolved_names
+
+      Gem.finish_resolve
+
+      assert_equal %w(a-1 b-1 c-1), loaded_spec_names
+      assert_equal [], unresolved_names
+    end
+  end
+
   def test_self_install
     spec_fetcher do |f|
       f.gem  'a', 1
@@ -492,7 +515,7 @@ def test_self_find_files_with_gemfile
     skip if RUBY_VERSION <= "1.8.7"
 
     cwd = File.expand_path("test/rubygems", @@project_dir)
-    $LOAD_PATH.unshift cwd
+    actual_load_path = $LOAD_PATH.unshift(cwd).dup
 
     discover_path = File.join 'lib', 'sff', 'discover.rb'
 
@@ -518,12 +541,12 @@ def test_self_find_files_with_gemfile
     expected = [
       File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
       File.join(foo1.full_gem_path, discover_path)
-    ]
+    ].sort
 
-    assert_equal expected, Gem.find_files('sff/discover')
-    assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
+    assert_equal expected, Gem.find_files('sff/discover').sort
+    assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
   ensure
-    assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7"
+    assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7"
   end
 
   def test_self_find_latest_files
diff --git test/rubygems/test_gem_commands_open_command.rb test/rubygems/test_gem_commands_open_command.rb
index 3ec38972e6..a96fa6ea23 100644
--- ruby-2.4.1/test/rubygems/test_gem_commands_open_command.rb
+++ ruby-2.4.1/test/rubygems/test_gem_commands_open_command.rb
@@ -24,7 +24,8 @@ def test_execute
     @cmd.options[:args] = %w[foo]
     @cmd.options[:editor] = "#{Gem.ruby} -e0 --"
 
-    spec = gem 'foo'
+    gem 'foo', '1.0.0'
+    spec = gem 'foo', '1.0.1'
     mock = MiniTest::Mock.new
     mock.expect(:call, true, [spec.full_gem_path])
 
diff --git test/rubygems/test_gem_commands_query_command.rb test/rubygems/test_gem_commands_query_command.rb
index 223f205b2d..d8d682b136 100644
--- ruby-2.4.1/test/rubygems/test_gem_commands_query_command.rb
+++ ruby-2.4.1/test/rubygems/test_gem_commands_query_command.rb
@@ -642,7 +642,7 @@ def test_execute_local_details
     assert_equal expected, @ui.output
   end
 
-  def test_execute_exact
+  def test_execute_exact_remote
     spec_fetcher do |fetcher|
       fetcher.spec 'coolgem-omg', 3
       fetcher.spec 'coolgem', '4.2.1'
@@ -665,6 +665,60 @@ def test_execute_exact
     assert_equal expected, @ui.output
   end
 
+  def test_execute_exact_local
+    spec_fetcher do |fetcher|
+      fetcher.spec 'coolgem-omg', 3
+      fetcher.spec 'coolgem', '4.2.1'
+      fetcher.spec 'wow_coolgem', 1
+    end
+
+    @cmd.handle_options %w[--exact coolgem]
+
+    use_ui @ui do
+      @cmd.execute
+    end
+
+    expected = <<-EOF
+
+*** LOCAL GEMS ***
+
+coolgem (4.2.1)
+    EOF
+
+    assert_equal expected, @ui.output
+  end
+
+  def test_execute_exact_multiple
+    spec_fetcher do |fetcher|
+      fetcher.spec 'coolgem-omg', 3
+      fetcher.spec 'coolgem', '4.2.1'
+      fetcher.spec 'wow_coolgem', 1
+
+      fetcher.spec 'othergem-omg', 3
+      fetcher.spec 'othergem', '1.2.3'
+      fetcher.spec 'wow_othergem', 1
+    end
+
+    @cmd.handle_options %w[--exact coolgem othergem]
+
+    use_ui @ui do
+      @cmd.execute
+    end
+
+    expected = <<-EOF
+
+*** LOCAL GEMS ***
+
+coolgem (4.2.1)
+
+*** LOCAL GEMS ***
+
+othergem (1.2.3)
+    EOF
+
+    assert_equal expected, @ui.output
+  end
+
   private
 
   def add_gems_to_fetcher
diff --git test/rubygems/test_gem_commands_sources_command.rb test/rubygems/test_gem_commands_sources_command.rb
index 014b4b4c12..d5b6d99419 100644
--- ruby-2.4.1/test/rubygems/test_gem_commands_sources_command.rb
+++ ruby-2.4.1/test/rubygems/test_gem_commands_sources_command.rb
@@ -108,6 +108,58 @@ def test_execute_add_redundant_source
     assert_equal '', @ui.error
   end
 
+  def test_execute_add_redundant_source_trailing_slash
+    # Remove pre-existing gem source (w/ slash)
+    repo_with_slash = "http://gems.example.com/"
+    @cmd.handle_options %W[--remove #{repo_with_slash}]
+    use_ui @ui do
+      @cmd.execute
+    end
+    source = Gem::Source.new repo_with_slash
+    assert_equal false, Gem.sources.include?(source)
+
+    expected = <<-EOF
+#{repo_with_slash} removed from sources
+    EOF
+
+    assert_equal expected, @ui.output
+    assert_equal '', @ui.error
+
+    # Re-add pre-existing gem source (w/o slash)
+    repo_without_slash = "http://gems.example.com"
+    @cmd.handle_options %W[--add #{repo_without_slash}]
+    use_ui @ui do
+      @cmd.execute
+    end
+    source = Gem::Source.new repo_without_slash
+    assert_equal true, Gem.sources.include?(source)
+
+    expected = <<-EOF
+http://gems.example.com/ removed from sources
+http://gems.example.com added to sources
+    EOF
+
+    assert_equal expected, @ui.output
+    assert_equal '', @ui.error
+
+    # Re-add original gem source (w/ slash)
+    @cmd.handle_options %W[--add #{repo_with_slash}]
+    use_ui @ui do
+      @cmd.execute
+    end
+    source = Gem::Source.new repo_with_slash
+    assert_equal true, Gem.sources.include?(source)
+
+    expected = <<-EOF
+http://gems.example.com/ removed from sources
+http://gems.example.com added to sources
+source http://gems.example.com/ already present in the cache
+    EOF
+
+    assert_equal expected, @ui.output
+    assert_equal '', @ui.error 
+  end
+
   def test_execute_add_http_rubygems_org
     http_rubygems_org = 'http://rubygems.org'
 
diff --git test/rubygems/test_gem_installer.rb test/rubygems/test_gem_installer.rb
index 6ceb2c6dfc..882981d344 100644
--- ruby-2.4.1/test/rubygems/test_gem_installer.rb
+++ ruby-2.4.1/test/rubygems/test_gem_installer.rb
@@ -62,7 +62,12 @@ def test_app_script_text
   end
 end
 
+if Gem.respond_to?(:activate_bin_path)
 load Gem.activate_bin_path('a', 'executable', version)
+else
+gem "a", version
+load Gem.bin_path("a", "executable", version)
+end
     EOF
 
     wrapper = @installer.app_script_text 'executable'
diff --git test/rubygems/test_require.rb test/rubygems/test_require.rb
index dd606e44d4..936f78fb2a 100644
--- ruby-2.4.1/test/rubygems/test_require.rb
+++ ruby-2.4.1/test/rubygems/test_require.rb
@@ -301,6 +301,17 @@ def test_default_gem_only
     assert_equal %w(default-2.0.0.0), loaded_spec_names
   end
 
+  def test_realworld_default_gem
+    skip "no default gems on ruby < 2.0" unless RUBY_VERSION >= "2"
+    cmd = <<-RUBY
+      $stderr = $stdout
+      require "json"
+      puts Gem.loaded_specs["json"].default_gem?
+    RUBY
+    output = Gem::Util.popen(Gem.ruby, "-e", cmd).strip
+    assert_equal "true", output
+  end
+
   def test_default_gem_and_normal_gem
     default_gem_spec = new_default_spec("default", "2.0.0.0",
                                         nil, "default/gem.rb")