rubygems-update 3.2.17 → 3.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/Manifest.txt +3 -0
  4. data/Rakefile +6 -6
  5. data/bundler/CHANGELOG.md +54 -0
  6. data/bundler/bundler.gemspec +2 -3
  7. data/bundler/lib/bundler.rb +2 -1
  8. data/bundler/lib/bundler/build_metadata.rb +2 -2
  9. data/bundler/lib/bundler/cli.rb +13 -33
  10. data/bundler/lib/bundler/cli/check.rb +4 -2
  11. data/bundler/lib/bundler/cli/install.rb +6 -7
  12. data/bundler/lib/bundler/cli/outdated.rb +9 -10
  13. data/bundler/lib/bundler/definition.rb +29 -82
  14. data/bundler/lib/bundler/feature_flag.rb +0 -2
  15. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  16. data/bundler/lib/bundler/fetcher/index.rb +0 -1
  17. data/bundler/lib/bundler/friendly_errors.rb +2 -4
  18. data/bundler/lib/bundler/index.rb +1 -2
  19. data/bundler/lib/bundler/installer.rb +1 -8
  20. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  21. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  22. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  23. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  24. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  25. data/bundler/lib/bundler/man/bundle-config.1 +1 -7
  26. data/bundler/lib/bundler/man/bundle-config.1.ronn +0 -8
  27. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  28. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  29. data/bundler/lib/bundler/man/bundle-gem.1 +1 -1
  30. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  31. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  32. data/bundler/lib/bundler/man/bundle-inject.1 +1 -1
  33. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  34. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  35. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  36. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  42. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle.1 +1 -1
  45. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  46. data/bundler/lib/bundler/plugin/api/source.rb +14 -0
  47. data/bundler/lib/bundler/resolver.rb +15 -96
  48. data/bundler/lib/bundler/resolver/spec_group.rb +0 -24
  49. data/bundler/lib/bundler/rubygems_ext.rb +2 -2
  50. data/bundler/lib/bundler/rubygems_integration.rb +4 -3
  51. data/bundler/lib/bundler/settings.rb +21 -3
  52. data/bundler/lib/bundler/source.rb +11 -0
  53. data/bundler/lib/bundler/source/rubygems.rb +24 -11
  54. data/bundler/lib/bundler/source/rubygems_aggregate.rb +64 -0
  55. data/bundler/lib/bundler/source_list.rb +35 -10
  56. data/bundler/lib/bundler/source_map.rb +58 -0
  57. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  58. data/bundler/lib/bundler/version.rb +1 -1
  59. data/lib/rubygems.rb +1 -1
  60. data/lib/rubygems/command.rb +2 -0
  61. data/lib/rubygems/commands/build_command.rb +1 -1
  62. data/lib/rubygems/config_file.rb +1 -1
  63. data/lib/rubygems/ext/ext_conf_builder.rb +4 -4
  64. data/lib/rubygems/installer.rb +4 -0
  65. data/lib/rubygems/request.rb +1 -1
  66. data/lib/rubygems/specification.rb +0 -2
  67. data/lib/rubygems/specification_policy.rb +5 -4
  68. data/lib/rubygems/test_case.rb +106 -18
  69. data/lib/rubygems/util/licenses.rb +107 -2
  70. data/rubygems-update.gemspec +1 -1
  71. data/setup.rb +1 -2
  72. data/test/rubygems/packages/ill-formatted-platform-1.0.0.10.gem +0 -0
  73. data/test/rubygems/test_bundled_ca.rb +2 -2
  74. data/test/rubygems/test_deprecate.rb +3 -3
  75. data/test/rubygems/test_gem.rb +33 -31
  76. data/test/rubygems/test_gem_bundler_version_finder.rb +3 -5
  77. data/test/rubygems/test_gem_command.rb +13 -1
  78. data/test/rubygems/test_gem_command_manager.rb +5 -5
  79. data/test/rubygems/test_gem_commands_build_command.rb +10 -10
  80. data/test/rubygems/test_gem_commands_cert_command.rb +36 -36
  81. data/test/rubygems/test_gem_commands_check_command.rb +5 -5
  82. data/test/rubygems/test_gem_commands_cleanup_command.rb +24 -24
  83. data/test/rubygems/test_gem_commands_contents_command.rb +3 -3
  84. data/test/rubygems/test_gem_commands_dependency_command.rb +2 -2
  85. data/test/rubygems/test_gem_commands_environment_command.rb +1 -1
  86. data/test/rubygems/test_gem_commands_fetch_command.rb +9 -9
  87. data/test/rubygems/test_gem_commands_help_command.rb +8 -1
  88. data/test/rubygems/test_gem_commands_install_command.rb +60 -60
  89. data/test/rubygems/test_gem_commands_list_command.rb +1 -1
  90. data/test/rubygems/test_gem_commands_lock_command.rb +1 -1
  91. data/test/rubygems/test_gem_commands_open_command.rb +8 -9
  92. data/test/rubygems/test_gem_commands_owner_command.rb +3 -3
  93. data/test/rubygems/test_gem_commands_pristine_command.rb +14 -14
  94. data/test/rubygems/test_gem_commands_push_command.rb +6 -11
  95. data/test/rubygems/test_gem_commands_query_command.rb +7 -7
  96. data/test/rubygems/test_gem_commands_server_command.rb +2 -2
  97. data/test/rubygems/test_gem_commands_setup_command.rb +21 -21
  98. data/test/rubygems/test_gem_commands_signin_command.rb +13 -6
  99. data/test/rubygems/test_gem_commands_sources_command.rb +5 -5
  100. data/test/rubygems/test_gem_commands_specification_command.rb +6 -6
  101. data/test/rubygems/test_gem_commands_uninstall_command.rb +4 -4
  102. data/test/rubygems/test_gem_commands_unpack_command.rb +2 -2
  103. data/test/rubygems/test_gem_commands_update_command.rb +10 -10
  104. data/test/rubygems/test_gem_commands_which_command.rb +3 -3
  105. data/test/rubygems/test_gem_commands_yank_command.rb +1 -1
  106. data/test/rubygems/test_gem_config_file.rb +9 -9
  107. data/test/rubygems/test_gem_dependency.rb +12 -6
  108. data/test/rubygems/test_gem_dependency_installer.rb +4 -4
  109. data/test/rubygems/test_gem_doctor.rb +30 -30
  110. data/test/rubygems/test_gem_ext_builder.rb +20 -20
  111. data/test/rubygems/test_gem_ext_cmake_builder.rb +4 -4
  112. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  113. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +14 -13
  114. data/test/rubygems/test_gem_ext_rake_builder.rb +1 -1
  115. data/test/rubygems/test_gem_gemcutter_utilities.rb +8 -14
  116. data/test/rubygems/test_gem_install_update_options.rb +9 -9
  117. data/test/rubygems/test_gem_installer.rb +162 -140
  118. data/test/rubygems/test_gem_local_remote_options.rb +1 -1
  119. data/test/rubygems/test_gem_package.rb +48 -48
  120. data/test/rubygems/test_gem_package_old.rb +9 -9
  121. data/test/rubygems/test_gem_package_tar_header.rb +5 -5
  122. data/test/rubygems/test_gem_package_tar_reader_entry.rb +8 -8
  123. data/test/rubygems/test_gem_package_tar_writer.rb +18 -20
  124. data/test/rubygems/test_gem_package_task.rb +2 -2
  125. data/test/rubygems/test_gem_path_support.rb +1 -1
  126. data/test/rubygems/test_gem_rdoc.rb +9 -9
  127. data/test/rubygems/test_gem_remote_fetcher.rb +17 -18
  128. data/test/rubygems/test_gem_request.rb +2 -2
  129. data/test/rubygems/test_gem_request_connection_pools.rb +1 -1
  130. data/test/rubygems/test_gem_request_set.rb +15 -14
  131. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +16 -16
  132. data/test/rubygems/test_gem_request_set_lockfile.rb +3 -3
  133. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +3 -3
  134. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +4 -4
  135. data/test/rubygems/test_gem_requirement.rb +13 -13
  136. data/test/rubygems/test_gem_resolver.rb +11 -11
  137. data/test/rubygems/test_gem_resolver_best_set.rb +1 -1
  138. data/test/rubygems/test_gem_resolver_git_set.rb +1 -1
  139. data/test/rubygems/test_gem_resolver_git_specification.rb +2 -2
  140. data/test/rubygems/test_gem_resolver_index_specification.rb +1 -1
  141. data/test/rubygems/test_gem_resolver_installer_set.rb +4 -4
  142. data/test/rubygems/test_gem_resolver_local_specification.rb +1 -1
  143. data/test/rubygems/test_gem_resolver_specification.rb +1 -1
  144. data/test/rubygems/test_gem_resolver_vendor_set.rb +2 -2
  145. data/test/rubygems/test_gem_security.rb +5 -5
  146. data/test/rubygems/test_gem_security_policy.rb +27 -27
  147. data/test/rubygems/test_gem_security_signer.rb +7 -7
  148. data/test/rubygems/test_gem_security_trust_dir.rb +4 -4
  149. data/test/rubygems/test_gem_server.rb +2 -2
  150. data/test/rubygems/test_gem_silent_ui.rb +9 -9
  151. data/test/rubygems/test_gem_source.rb +2 -2
  152. data/test/rubygems/test_gem_source_fetch_problem.rb +1 -1
  153. data/test/rubygems/test_gem_source_git.rb +11 -11
  154. data/test/rubygems/test_gem_source_specific_file.rb +1 -1
  155. data/test/rubygems/test_gem_spec_fetcher.rb +1 -1
  156. data/test/rubygems/test_gem_specification.rb +86 -106
  157. data/test/rubygems/test_gem_stream_ui.rb +1 -1
  158. data/test/rubygems/test_gem_stub_specification.rb +4 -4
  159. data/test/rubygems/test_gem_uninstaller.rb +16 -16
  160. data/test/rubygems/test_gem_util.rb +8 -6
  161. data/test/rubygems/test_gem_version.rb +4 -13
  162. data/test/rubygems/test_kernel.rb +6 -4
  163. data/test/rubygems/test_project_sanity.rb +1 -1
  164. data/test/rubygems/test_remote_fetch_error.rb +1 -1
  165. data/test/rubygems/test_require.rb +12 -14
  166. data/test/test_changelog_generator.rb +1 -2
  167. metadata +6 -3
@@ -21,14 +21,10 @@ module Bundler
21
21
  @version = exemplary_spec.version
22
22
  @source = exemplary_spec.source
23
23
 
24
- @all_platforms = relevant_platforms
25
24
  @activated_platforms = relevant_platforms
26
25
  @dependencies = Hash.new do |dependencies, platforms|
27
26
  dependencies[platforms] = dependencies_for(platforms)
28
27
  end
29
- @partitioned_dependency_names = Hash.new do |partitioned_dependency_names, platforms|
30
- partitioned_dependency_names[platforms] = partitioned_dependency_names_for(platforms)
31
- end
32
28
  @specs = specs
33
29
  end
34
30
 
@@ -45,14 +41,6 @@ module Bundler
45
41
  end.flatten.compact.uniq
46
42
  end
47
43
 
48
- def activate_platform!(platform)
49
- self.activated_platforms = [platform]
50
- end
51
-
52
- def activate_all_platforms!
53
- self.activated_platforms = @all_platforms
54
- end
55
-
56
44
  def to_s
57
45
  activated_platforms_string = sorted_activated_platforms.join(", ")
58
46
  "#{name} (#{version}) (#{activated_platforms_string})"
@@ -62,10 +50,6 @@ module Bundler
62
50
  @dependencies[activated_platforms]
63
51
  end
64
52
 
65
- def partitioned_dependency_names_for_activated_platforms
66
- @partitioned_dependency_names[activated_platforms]
67
- end
68
-
69
53
  def ==(other)
70
54
  return unless other.is_a?(SpecGroup)
71
55
  name == other.name &&
@@ -100,14 +84,6 @@ module Bundler
100
84
  end.flatten
101
85
  end
102
86
 
103
- def partitioned_dependency_names_for(platforms)
104
- return @dependencies[platforms].map(&:name), [] if platforms.size == 1
105
-
106
- @dependencies[platforms].partition do |dep_proxy|
107
- @dependencies[platforms].count {|dp| dp.dep == dep_proxy.dep } == platforms.size
108
- end.map {|deps| deps.map(&:name) }
109
- end
110
-
111
87
  def __dependencies(platform)
112
88
  dependencies = []
113
89
  @specs[platform].first.dependencies.each do |dep|
@@ -105,7 +105,7 @@ module Gem
105
105
  end
106
106
 
107
107
  class Dependency
108
- attr_accessor :source, :groups, :all_sources
108
+ attr_accessor :source, :groups
109
109
 
110
110
  alias_method :eql?, :==
111
111
 
@@ -116,7 +116,7 @@ module Gem
116
116
  end
117
117
 
118
118
  def to_yaml_properties
119
- instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
119
+ instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
120
120
  end
121
121
 
122
122
  def to_lock
@@ -526,13 +526,14 @@ module Bundler
526
526
  Bundler::Retry.new("download gem from #{uri}").attempts do
527
527
  fetcher.download(spec, uri, path)
528
528
  end
529
+ rescue Gem::RemoteFetcher::FetchError => e
530
+ raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
529
531
  end
530
532
 
531
533
  def gem_remote_fetcher
532
- require "resolv"
534
+ require "rubygems/remote_fetcher"
533
535
  proxy = configuration[:http_proxy]
534
- dns = Resolv::DNS.new
535
- Gem::RemoteFetcher.new(proxy, dns)
536
+ Gem::RemoteFetcher.new(proxy)
536
537
  end
537
538
 
538
539
  def gem_from_path(path, policy = nil)
@@ -16,12 +16,10 @@ module Bundler
16
16
  clean
17
17
  default_install_uses_path
18
18
  deployment
19
- deployment_means_frozen
20
19
  disable_checksum_validation
21
20
  disable_exec_load
22
21
  disable_local_branch_check
23
22
  disable_local_revision_check
24
- disable_multisource
25
23
  disable_shared_gems
26
24
  disable_version_check
27
25
  force_ruby_platform
@@ -211,6 +209,13 @@ module Bundler
211
209
  locations
212
210
  end
213
211
 
212
+ def processor_count
213
+ require "etc"
214
+ Etc.nprocessors
215
+ rescue StandardError
216
+ 1
217
+ end
218
+
214
219
  # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
215
220
  def path
216
221
  configs.each do |_level, settings|
@@ -443,7 +448,20 @@ module Bundler
443
448
  valid_file = file.exist? && !file.size.zero?
444
449
  return {} unless valid_file
445
450
  require_relative "yaml_serializer"
446
- YAMLSerializer.load file.read
451
+ YAMLSerializer.load(file.read).inject({}) do |config, (k, v)|
452
+ new_k = k
453
+
454
+ if k.include?("-")
455
+ Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
456
+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
457
+ "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
458
+
459
+ new_k = k.gsub("-", "___")
460
+ end
461
+
462
+ config[new_k] = v
463
+ config
464
+ end
447
465
  end
448
466
  end
449
467
 
@@ -7,6 +7,7 @@ module Bundler
7
7
  autoload :Metadata, File.expand_path("source/metadata", __dir__)
8
8
  autoload :Path, File.expand_path("source/path", __dir__)
9
9
  autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
10
+ autoload :RubygemsAggregate, File.expand_path("source/rubygems_aggregate", __dir__)
10
11
 
11
12
  attr_accessor :dependency_names
12
13
 
@@ -35,10 +36,16 @@ module Bundler
35
36
 
36
37
  def local!; end
37
38
 
39
+ def local_only!; end
40
+
38
41
  def cached!; end
39
42
 
40
43
  def remote!; end
41
44
 
45
+ def add_dependency_names(names)
46
+ @dependency_names = Array(dependency_names) | Array(names)
47
+ end
48
+
42
49
  # it's possible that gems from one source depend on gems from some
43
50
  # other source, so now we download gemspecs and iterate over those
44
51
  # dependencies, looking for gems we don't have info on yet.
@@ -48,6 +55,10 @@ module Bundler
48
55
  specs.dependency_names
49
56
  end
50
57
 
58
+ def spec_names
59
+ specs.spec_names
60
+ end
61
+
51
62
  def include?(other)
52
63
  other == self
53
64
  end
@@ -26,6 +26,12 @@ module Bundler
26
26
  Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
27
  end
28
28
 
29
+ def local_only!
30
+ @specs = nil
31
+ @allow_local = true
32
+ @allow_remote = false
33
+ end
34
+
29
35
  def local!
30
36
  return if @allow_local
31
37
 
@@ -61,12 +67,12 @@ module Bundler
61
67
  o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
62
68
  end
63
69
 
64
- def disable_multisource?
65
- @remotes.size <= 1
70
+ def multiple_remotes?
71
+ @remotes.size > 1
66
72
  end
67
73
 
68
74
  def can_lock?(spec)
69
- return super if disable_multisource?
75
+ return super unless multiple_remotes?
70
76
  spec.source.is_a?(Rubygems)
71
77
  end
72
78
 
@@ -259,8 +265,16 @@ module Bundler
259
265
  !equivalent
260
266
  end
261
267
 
268
+ def spec_names
269
+ if @allow_remote && dependency_api_available?
270
+ remote_specs.spec_names
271
+ else
272
+ []
273
+ end
274
+ end
275
+
262
276
  def unmet_deps
263
- if @allow_remote && api_fetchers.any?
277
+ if @allow_remote && dependency_api_available?
264
278
  remote_specs.unmet_dependency_names
265
279
  else
266
280
  []
@@ -276,7 +290,7 @@ module Bundler
276
290
 
277
291
  def double_check_for(unmet_dependency_names)
278
292
  return unless @allow_remote
279
- return unless api_fetchers.any?
293
+ return unless dependency_api_available?
280
294
 
281
295
  unmet_dependency_names = unmet_dependency_names.call
282
296
  unless unmet_dependency_names.nil?
@@ -298,17 +312,20 @@ module Bundler
298
312
  remote_specs.each do |spec|
299
313
  case spec
300
314
  when EndpointSpecification, Gem::Specification, StubSpecification, LazySpecification
301
- names.concat(spec.runtime_dependencies)
315
+ names.concat(spec.runtime_dependencies.map(&:name))
302
316
  when RemoteSpecification # from the full index
303
317
  return nil
304
318
  else
305
319
  raise "unhandled spec type (#{spec.inspect})"
306
320
  end
307
321
  end
308
- names.map!(&:name) if names
309
322
  names
310
323
  end
311
324
 
325
+ def dependency_api_available?
326
+ api_fetchers.any?
327
+ end
328
+
312
329
  protected
313
330
 
314
331
  def credless_remotes
@@ -387,10 +404,6 @@ module Bundler
387
404
  next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
388
405
  s ||= Bundler.rubygems.spec_from_gem(gemfile)
389
406
  s.source = self
390
- if Bundler.rubygems.spec_missing_extensions?(s, false)
391
- Bundler.ui.debug "Source #{self} is ignoring #{s} because it is missing extensions"
392
- next
393
- end
394
407
  idx << s
395
408
  end
396
409
 
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Source
5
+ class RubygemsAggregate
6
+ attr_reader :source_map, :sources
7
+
8
+ def initialize(sources, source_map)
9
+ @sources = sources
10
+ @source_map = source_map
11
+
12
+ @index = build_index
13
+ end
14
+
15
+ def specs
16
+ @index
17
+ end
18
+
19
+ def to_s
20
+ "any of the sources"
21
+ end
22
+
23
+ private
24
+
25
+ def build_index
26
+ Index.build do |idx|
27
+ dependency_names = source_map.pinned_spec_names
28
+
29
+ sources.all_sources.each do |source|
30
+ source.dependency_names = dependency_names - source_map.pinned_spec_names(source)
31
+ idx.add_source source.specs
32
+ dependency_names.concat(source.unmet_deps).uniq!
33
+ end
34
+
35
+ double_check_for_index(idx, dependency_names)
36
+ end
37
+ end
38
+
39
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
40
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
41
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
42
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
43
+ # each spec we found, we add all possible versions from all sources to the index.
44
+ def double_check_for_index(idx, dependency_names)
45
+ pinned_names = source_map.pinned_spec_names
46
+
47
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
48
+ unmet_dependency_names = lambda do
49
+ return names unless names == :names
50
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
51
+ return names = nil if new_names.compact!
52
+ names = new_names.flatten(1).concat(dependency_names)
53
+ names.uniq!
54
+ names -= pinned_names
55
+ names
56
+ end
57
+
58
+ sources.all_sources.each do |source|
59
+ source.double_check_for(unmet_dependency_names)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -21,15 +21,19 @@ module Bundler
21
21
  @rubygems_sources = []
22
22
  @metadata_source = Source::Metadata.new
23
23
 
24
- @disable_multisource = true
24
+ @merged_gem_lockfile_sections = false
25
25
  end
26
26
 
27
- def disable_multisource?
28
- @disable_multisource
27
+ def merged_gem_lockfile_sections?
28
+ @merged_gem_lockfile_sections
29
29
  end
30
30
 
31
31
  def merged_gem_lockfile_sections!
32
- @disable_multisource = false
32
+ @merged_gem_lockfile_sections = true
33
+ end
34
+
35
+ def aggregate_global_source?
36
+ global_rubygems_source.multiple_remotes?
33
37
  end
34
38
 
35
39
  def add_path_source(options = {})
@@ -70,7 +74,11 @@ module Bundler
70
74
  end
71
75
 
72
76
  def rubygems_sources
73
- @rubygems_sources + [global_rubygems_source]
77
+ non_global_rubygems_sources + [global_rubygems_source]
78
+ end
79
+
80
+ def non_global_rubygems_sources
81
+ @rubygems_sources
74
82
  end
75
83
 
76
84
  def rubygems_remotes
@@ -81,16 +89,27 @@ module Bundler
81
89
  path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
82
90
  end
83
91
 
92
+ def non_default_explicit_sources
93
+ all_sources - [default_source, metadata_source]
94
+ end
95
+
84
96
  def get(source)
85
97
  source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
86
98
  end
87
99
 
88
100
  def lock_sources
89
- lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
90
- if disable_multisource?
91
- lock_sources + rubygems_sources.sort_by(&:to_s).uniq
101
+ lock_other_sources + lock_rubygems_sources
102
+ end
103
+
104
+ def lock_other_sources
105
+ (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
106
+ end
107
+
108
+ def lock_rubygems_sources
109
+ if merged_gem_lockfile_sections?
110
+ [combine_rubygems_sources]
92
111
  else
93
- lock_sources << combine_rubygems_sources
112
+ rubygems_sources.sort_by(&:to_s).uniq
94
113
  end
95
114
  end
96
115
 
@@ -104,7 +123,7 @@ module Bundler
104
123
  end
105
124
  end
106
125
 
107
- replacement_rubygems = !disable_multisource? &&
126
+ replacement_rubygems = merged_gem_lockfile_sections? &&
108
127
  replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
109
128
  @global_rubygems_source = replacement_rubygems if replacement_rubygems
110
129
 
@@ -113,6 +132,10 @@ module Bundler
113
132
  false
114
133
  end
115
134
 
135
+ def local_only!
136
+ all_sources.each(&:local_only!)
137
+ end
138
+
116
139
  def cached!
117
140
  all_sources.each(&:cached!)
118
141
  end
@@ -162,6 +185,8 @@ module Bundler
162
185
  end
163
186
 
164
187
  def equal_source?(source, other_source)
188
+ return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems) && !merged_gem_lockfile_sections?
189
+
165
190
  source == other_source
166
191
  end
167
192
 
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class SourceMap
5
+ attr_reader :sources, :dependencies
6
+
7
+ def initialize(sources, dependencies)
8
+ @sources = sources
9
+ @dependencies = dependencies
10
+ end
11
+
12
+ def pinned_spec_names(skip = nil)
13
+ direct_requirements.reject {|_, source| source == skip }.keys
14
+ end
15
+
16
+ def all_requirements
17
+ requirements = direct_requirements.dup
18
+
19
+ unmet_deps = sources.non_default_explicit_sources.map do |source|
20
+ (source.spec_names - pinned_spec_names).each do |indirect_dependency_name|
21
+ previous_source = requirements[indirect_dependency_name]
22
+ if previous_source.nil?
23
+ requirements[indirect_dependency_name] = source
24
+ else
25
+ no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
26
+
27
+ msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
28
+ msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
29
+ msg << "You #{no_ambiguous_sources ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
30
+ msg = msg.join("\n")
31
+
32
+ raise SecurityError, msg if no_ambiguous_sources
33
+ Bundler.ui.warn "Warning: #{msg}"
34
+ end
35
+ end
36
+
37
+ source.unmet_deps
38
+ end
39
+
40
+ sources.default_source.add_dependency_names(unmet_deps.flatten - requirements.keys)
41
+
42
+ requirements
43
+ end
44
+
45
+ def direct_requirements
46
+ @direct_requirements ||= begin
47
+ requirements = {}
48
+ default = sources.default_source
49
+ dependencies.each do |dep|
50
+ dep_source = dep.source || default
51
+ dep_source.add_dependency_names(dep.name)
52
+ requirements[dep.name] = dep_source
53
+ end
54
+ requirements
55
+ end
56
+ end
57
+ end
58
+ end