bundler 2.2.12 → 2.2.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c743279657baa7fb86bcbe8b49fe758261f53161679c28c0d9d4251f7c32626
4
- data.tar.gz: 127f8571d11fd6f22612ee988bb6abec9035cfa9df65949994255253b4c108b7
3
+ metadata.gz: e4227db15ba56c781814845c3e7c2811def8bba66c074098d04496cf3f7ce3ed
4
+ data.tar.gz: '0295d490ed0dcf0989468a1a25b3b233c618006882757cbbf5a99e179b009568'
5
5
  SHA512:
6
- metadata.gz: 284b277cfa1bdd0d99da2eef27a8ea3ae97c2e4f0ca1b6622bb276fdf7f9de4e46c44f3aaffc94328569df7057c6cb1dd091702f35b5a2bb808764df708b9c14
7
- data.tar.gz: 606a3cbbbb7186a5fdfc8a6c68f9f50cba4e8634506f8a7fba8ff4fbdbae0013f8e551a2f9d97980a20c781f79ef542c9d664cf84b6a029e3649349a27260422
6
+ metadata.gz: fa78e4e46d7b7fe666950c26fd47df524d7af57612c4e584e088a7a10aa140db5eb243b0688f993dc3586a7b5c4cb2357488a237715b618891747b328d94d01a
7
+ data.tar.gz: f1baab0b6a8b0c9ccf1c9bdafb7e6068252ba8fac05f96f50540320f47d4da8fa42ecae264e7b082fc1c50d4c0ff7cb456a928b2ffb07d0ca79e84d6272d1b54
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 2.2.13 (March 3, 2021)
2
+
3
+ ## Enhancements:
4
+
5
+ - Respect user configured default branch in README links in new generated gems [#4303](https://github.com/rubygems/rubygems/pull/4303)
6
+
7
+ ## Bug fixes:
8
+
9
+ - Fix gems sometimes being pulled from irrelevant sources [#4418](https://github.com/rubygems/rubygems/pull/4418)
10
+
1
11
  # 2.2.12 (March 1, 2021)
2
12
 
3
13
  ## Bug fixes:
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2021-03-01".freeze
8
- @git_commit_sha = "1de3f8de73".freeze
7
+ @built_at = "2021-03-03".freeze
8
+ @git_commit_sha = "9b15ab18c4".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -39,11 +39,11 @@ module Bundler
39
39
  constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
40
40
  constant_array = constant_name.split("::")
41
41
 
42
- git_installed = Bundler.git_present?
42
+ use_git = Bundler.git_present? && options[:git]
43
43
 
44
- git_author_name = git_installed ? `git config user.name`.chomp : ""
45
- github_username = git_installed ? `git config github.user`.chomp : ""
46
- git_user_email = git_installed ? `git config user.email`.chomp : ""
44
+ git_author_name = use_git ? `git config user.name`.chomp : ""
45
+ github_username = use_git ? `git config github.user`.chomp : ""
46
+ git_user_email = use_git ? `git config user.email`.chomp : ""
47
47
 
48
48
  config = {
49
49
  :name => name,
@@ -58,6 +58,7 @@ module Bundler
58
58
  :ext => options[:ext],
59
59
  :exe => options[:exe],
60
60
  :bundler_version => bundler_dependency_version,
61
+ :git => use_git,
61
62
  :github_username => github_username.empty? ? "[USERNAME]" : github_username,
62
63
  :required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
63
64
  }
@@ -79,7 +80,7 @@ module Bundler
79
80
  bin/setup
80
81
  ]
81
82
 
82
- templates.merge!("gitignore.tt" => ".gitignore") if Bundler.git_present?
83
+ templates.merge!("gitignore.tt" => ".gitignore") if use_git
83
84
 
84
85
  if test_framework = ask_and_set_test_framework
85
86
  config[:test] = test_framework
@@ -175,24 +176,31 @@ module Bundler
175
176
  )
176
177
  end
177
178
 
179
+ if File.exist?(target) && !File.directory?(target)
180
+ Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`."
181
+ exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError]
182
+ end
183
+
184
+ if use_git
185
+ Bundler.ui.info "Initializing git repo in #{target}"
186
+ `git init #{target}`
187
+
188
+ config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
189
+ end
190
+
178
191
  templates.each do |src, dst|
179
192
  destination = target.join(dst)
180
- SharedHelpers.filesystem_access(destination) do
181
- thor.template("newgem/#{src}", destination, config)
182
- end
193
+ thor.template("newgem/#{src}", destination, config)
183
194
  end
184
195
 
185
196
  executables.each do |file|
186
- SharedHelpers.filesystem_access(target.join(file)) do |path|
187
- executable = (path.stat.mode | 0o111)
188
- path.chmod(executable)
189
- end
197
+ path = target.join(file)
198
+ executable = (path.stat.mode | 0o111)
199
+ path.chmod(executable)
190
200
  end
191
201
 
192
- if Bundler.git_present? && options[:git]
193
- Bundler.ui.info "Initializing git repo in #{target}"
202
+ if use_git
194
203
  Dir.chdir(target) do
195
- `git init`
196
204
  `git add .`
197
205
  end
198
206
  end
@@ -202,8 +210,6 @@ module Bundler
202
210
 
203
211
  Bundler.ui.info "Gem '#{name}' was successfully created. " \
204
212
  "For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html"
205
- rescue Errno::EEXIST => e
206
- raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
207
213
  end
208
214
 
209
215
  private
@@ -264,7 +264,7 @@ module Bundler
264
264
  # Run a resolve against the locally available gems
265
265
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
266
266
  expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, @remote)
267
- Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
267
+ Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
268
268
  end
269
269
  end
270
270
  end
@@ -656,19 +656,20 @@ module Bundler
656
656
  def converge_rubygems_sources
657
657
  return false if Bundler.feature_flag.disable_multisource?
658
658
 
659
- changes = false
660
-
661
659
  # Get the RubyGems sources from the Gemfile.lock
662
660
  locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
661
+ return false if locked_gem_sources.empty?
662
+
663
663
  # Get the RubyGems remotes from the Gemfile
664
664
  actual_remotes = sources.rubygems_remotes
665
+ return false if actual_remotes.empty?
666
+
667
+ changes = false
665
668
 
666
669
  # If there is a RubyGems source in both
667
- if !locked_gem_sources.empty? && !actual_remotes.empty?
668
- locked_gem_sources.each do |locked_gem|
669
- # Merge the remotes from the Gemfile into the Gemfile.lock
670
- changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
671
- end
670
+ locked_gem_sources.each do |locked_gem|
671
+ # Merge the remotes from the Gemfile into the Gemfile.lock
672
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
672
673
  end
673
674
 
674
675
  changes
@@ -893,30 +894,18 @@ module Bundler
893
894
  # Record the specs available in each gem's source, so that those
894
895
  # specs will be available later when the resolver knows where to
895
896
  # look for that gemspec (or its dependencies)
896
- default = sources.default_source
897
- source_requirements = { :default => default }
898
- default = nil unless Bundler.feature_flag.disable_multisource?
899
- dependencies.each do |dep|
900
- next unless source = dep.source || default
901
- source_requirements[dep.name] = source
902
- end
897
+ source_requirements = { :default => sources.default_source }.merge(dependency_source_requirements)
903
898
  metadata_dependencies.each do |dep|
904
899
  source_requirements[dep.name] = sources.metadata_source
905
900
  end
901
+ source_requirements[:global] = index unless Bundler.feature_flag.disable_multisource?
906
902
  source_requirements[:default_bundler] = source_requirements["bundler"] || source_requirements[:default]
907
903
  source_requirements["bundler"] = sources.metadata_source # needs to come last to override
908
904
  source_requirements
909
905
  end
910
906
 
911
907
  def pinned_spec_names(skip = nil)
912
- pinned_names = []
913
- default = Bundler.feature_flag.disable_multisource? && sources.default_source
914
- @dependencies.each do |dep|
915
- next unless dep_source = dep.source || default
916
- next if dep_source == skip
917
- pinned_names << dep.name
918
- end
919
- pinned_names
908
+ dependency_source_requirements.reject {|_, source| source == skip }.keys
920
909
  end
921
910
 
922
911
  def requested_groups
@@ -973,5 +962,17 @@ module Bundler
973
962
 
974
963
  Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
975
964
  end
965
+
966
+ def dependency_source_requirements
967
+ @dependency_source_requirements ||= begin
968
+ source_requirements = {}
969
+ default = sources.default_source
970
+ dependencies.each do |dep|
971
+ dep_source = dep.source || default
972
+ source_requirements[dep.name] = dep_source
973
+ end
974
+ source_requirements
975
+ end
976
+ end
976
977
  end
977
978
  end
data/lib/bundler/dsl.rb CHANGED
@@ -24,6 +24,9 @@ module Bundler
24
24
  def initialize
25
25
  @source = nil
26
26
  @sources = SourceList.new
27
+
28
+ @global_rubygems_sources = []
29
+
27
30
  @git_sources = {}
28
31
  @dependencies = []
29
32
  @groups = []
@@ -45,6 +48,7 @@ module Bundler
45
48
  @gemfiles << expanded_gemfile_path
46
49
  contents ||= Bundler.read_file(@gemfile.to_s)
47
50
  instance_eval(contents.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
51
+ check_primary_source_safety
48
52
  rescue Exception => e # rubocop:disable Lint/RescueException
49
53
  message = "There was an error " \
50
54
  "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -164,8 +168,7 @@ module Bundler
164
168
  elsif block_given?
165
169
  with_source(@sources.add_rubygems_source("remotes" => source), &blk)
166
170
  else
167
- check_primary_source_safety(@sources)
168
- @sources.global_rubygems_source = source
171
+ @global_rubygems_sources << source
169
172
  end
170
173
  end
171
174
 
@@ -183,24 +186,14 @@ module Bundler
183
186
  end
184
187
 
185
188
  def path(path, options = {}, &blk)
186
- unless block_given?
187
- msg = "You can no longer specify a path source by itself. Instead, \n" \
188
- "either use the :path option on a gem, or specify the gems that \n" \
189
- "bundler should find in the path source by passing a block to \n" \
190
- "the path method, like: \n\n" \
191
- " path 'dir/containing/rails' do\n" \
192
- " gem 'rails'\n" \
193
- " end\n\n"
194
-
195
- raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
196
- SharedHelpers.major_deprecation(2, msg.strip)
197
- end
198
-
199
189
  source_options = normalize_hash(options).merge(
200
190
  "path" => Pathname.new(path),
201
191
  "root_path" => gemfile_root,
202
192
  "gemspec" => gemspecs.find {|g| g.name == options["name"] }
203
193
  )
194
+
195
+ source_options["global"] = true unless block_given?
196
+
204
197
  source = @sources.add_path_source(source_options)
205
198
  with_source(source, &blk)
206
199
  end
@@ -279,6 +272,11 @@ module Bundler
279
272
  raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile"
280
273
  end
281
274
 
275
+ def check_primary_source_safety
276
+ check_path_source_safety
277
+ check_rubygems_source_safety
278
+ end
279
+
282
280
  private
283
281
 
284
282
  def add_git_sources
@@ -440,17 +438,33 @@ repo_name ||= user_name
440
438
  end
441
439
  end
442
440
 
443
- def check_primary_source_safety(source_list)
444
- return if source_list.rubygems_primary_remotes.empty? && source_list.global_rubygems_source.nil?
441
+ def check_path_source_safety
442
+ return if @sources.global_path_source.nil?
443
+
444
+ msg = "You can no longer specify a path source by itself. Instead, \n" \
445
+ "either use the :path option on a gem, or specify the gems that \n" \
446
+ "bundler should find in the path source by passing a block to \n" \
447
+ "the path method, like: \n\n" \
448
+ " path 'dir/containing/rails' do\n" \
449
+ " gem 'rails'\n" \
450
+ " end\n\n"
451
+
452
+ SharedHelpers.major_deprecation(2, msg.strip)
453
+ end
454
+
455
+ def check_rubygems_source_safety
456
+ @sources.global_rubygems_source = @global_rubygems_sources.shift
457
+ return if @global_rubygems_sources.empty?
458
+
459
+ @global_rubygems_sources.each do |source|
460
+ @sources.add_rubygems_remote(source)
461
+ end
445
462
 
446
463
  if Bundler.feature_flag.disable_multisource?
447
464
  msg = "This Gemfile contains multiple primary sources. " \
448
465
  "Each source after the first must include a block to indicate which gems " \
449
- "should come from that source"
450
- unless Bundler.feature_flag.bundler_2_mode?
451
- msg += ". To downgrade this error to a warning, run " \
452
- "`bundle config unset disable_multisource`"
453
- end
466
+ "should come from that source. To downgrade this error to a warning, run " \
467
+ "`bundle config unset disable_multisource`"
454
468
  raise GemfileEvalError, msg
455
469
  else
456
470
  Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
@@ -50,6 +50,7 @@ def gemfile(install = false, options = {}, &gemfile)
50
50
  Bundler::Plugin.gemfile_install(&gemfile) if Bundler.feature_flag.plugins?
51
51
  builder = Bundler::Dsl.new
52
52
  builder.instance_eval(&gemfile)
53
+ builder.check_primary_source_safety
53
54
 
54
55
  Bundler.settings.temporary(:frozen => false) do
55
56
  definition = builder.to_definition(nil, true)
@@ -64,8 +64,6 @@ module Bundler
64
64
  @state = nil
65
65
  @specs = {}
66
66
 
67
- @rubygems_aggregate = Source::Rubygems.new
68
-
69
67
  if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
70
68
  raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
71
69
  "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
@@ -89,7 +87,6 @@ module Bundler
89
87
  send("parse_#{@state}", line)
90
88
  end
91
89
  end
92
- @sources << @rubygems_aggregate unless Bundler.feature_flag.disable_multisource?
93
90
  @specs = @specs.values.sort_by(&:identifier)
94
91
  warn_for_outdated_bundler_version
95
92
  rescue ArgumentError => e
@@ -134,16 +131,19 @@ module Bundler
134
131
  @sources << @current_source
135
132
  end
136
133
  when GEM
137
- if Bundler.feature_flag.disable_multisource?
134
+ source_remotes = Array(@opts["remote"])
135
+
136
+ if source_remotes.size == 1
138
137
  @opts["remotes"] = @opts.delete("remote")
139
138
  @current_source = TYPES[@type].from_lock(@opts)
140
- @sources << @current_source
141
139
  else
142
- Array(@opts["remote"]).each do |url|
143
- @rubygems_aggregate.add_remote(url)
140
+ source_remotes.each do |url|
141
+ rubygems_aggregate.add_remote(url)
144
142
  end
145
- @current_source = @rubygems_aggregate
143
+ @current_source = rubygems_aggregate
146
144
  end
145
+
146
+ @sources << @current_source
147
147
  when PLUGIN
148
148
  @current_source = Plugin.source_from_lock(@opts)
149
149
  @sources << @current_source
@@ -245,5 +245,9 @@ module Bundler
245
245
  def parse_ruby(line)
246
246
  @ruby_version = line.strip
247
247
  end
248
+
249
+ def rubygems_aggregate
250
+ @rubygems_aggregate ||= Source::Rubygems.new
251
+ end
248
252
  end
249
253
  end
@@ -105,6 +105,7 @@ module Bundler
105
105
  else
106
106
  builder.eval_gemfile(gemfile)
107
107
  end
108
+ builder.check_primary_source_safety
108
109
  definition = builder.to_definition(nil, true)
109
110
 
110
111
  return if definition.dependencies.empty?
@@ -16,15 +16,13 @@ module Bundler
16
16
 
17
17
  version = options[:version] || [">= 0"]
18
18
 
19
- Bundler.settings.temporary(:disable_multisource => false) do
20
- if options[:git]
21
- install_git(names, version, options)
22
- elsif options[:local_git]
23
- install_local_git(names, version, options)
24
- else
25
- sources = options[:source] || Bundler.rubygems.sources
26
- install_rubygems(names, version, sources)
27
- end
19
+ if options[:git]
20
+ install_git(names, version, options)
21
+ elsif options[:local_git]
22
+ install_local_git(names, version, options)
23
+ else
24
+ sources = options[:source] || Bundler.rubygems.sources
25
+ install_rubygems(names, version, sources)
28
26
  end
29
27
  end
30
28
 
@@ -79,7 +77,7 @@ module Bundler
79
77
  source_list = SourceList.new
80
78
 
81
79
  source_list.add_git_source(git_source_options) if git_source_options
82
- source_list.add_rubygems_source("remotes" => rubygems_source) if rubygems_source
80
+ source_list.global_rubygems_source = rubygems_source if rubygems_source
83
81
 
84
82
  deps = names.map {|name| Dependency.new name, version }
85
83
 
@@ -17,6 +17,10 @@ module Bundler
17
17
  path_sources + git_sources + rubygems_sources + [metadata_source]
18
18
  end
19
19
 
20
+ def default_source
21
+ git_sources.first || global_rubygems_source
22
+ end
23
+
20
24
  private
21
25
 
22
26
  def rubygems_aggregate_class
@@ -17,16 +17,21 @@ module Bundler
17
17
  # ==== Returns
18
18
  # <GemBundle>,nil:: If the list of dependencies can be resolved, a
19
19
  # collection of gemspecs is returned. Otherwise, nil is returned.
20
- def self.resolve(requirements, index, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
20
+ def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
21
21
  base = SpecSet.new(base) unless base.is_a?(SpecSet)
22
- resolver = new(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
22
+ resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
23
23
  result = resolver.start(requirements)
24
24
  SpecSet.new(result)
25
25
  end
26
26
 
27
- def initialize(index, source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
28
- @index = index
27
+ def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
29
28
  @source_requirements = source_requirements
29
+
30
+ @index_requirements = source_requirements.each_with_object({}) do |source_requirement, index_requirements|
31
+ name, source = source_requirement
32
+ index_requirements[name] = name == :global ? source : source.specs
33
+ end
34
+
30
35
  @base = base
31
36
  @resolver = Molinillo::Resolver.new(self, self)
32
37
  @search_for = {}
@@ -40,7 +45,7 @@ module Bundler
40
45
  @resolving_only_for_ruby = platforms == [Gem::Platform::RUBY]
41
46
  @gem_version_promoter = gem_version_promoter
42
47
  @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
43
- @lockfile_uses_separate_rubygems_sources = Bundler.feature_flag.disable_multisource?
48
+ @no_aggregate_global_source = @source_requirements[:global].nil?
44
49
 
45
50
  @variant_specific_names = []
46
51
  @generic_names = ["Ruby\0", "RubyGems\0"]
@@ -125,8 +130,7 @@ module Bundler
125
130
  dependency = dependency_proxy.dep
126
131
  name = dependency.name
127
132
  search_result = @search_for[dependency_proxy] ||= begin
128
- index = index_for(dependency)
129
- results = index.search(dependency, @base[name])
133
+ results = results_for(dependency, @base[name])
130
134
 
131
135
  if vertex = @base_dg.vertex_named(name)
132
136
  locked_requirement = vertex.payload.requirement
@@ -196,22 +200,22 @@ module Bundler
196
200
  end
197
201
 
198
202
  def index_for(dependency)
199
- source = @source_requirements[dependency.name]
203
+ source = @index_requirements[dependency.name]
200
204
  if source
201
- source.specs
202
- elsif @lockfile_uses_separate_rubygems_sources
205
+ source
206
+ elsif @no_aggregate_global_source
203
207
  Index.build do |idx|
204
- if dependency.all_sources
205
- dependency.all_sources.each {|s| idx.add_source(s.specs) if s }
206
- else
207
- idx.add_source @source_requirements[:default].specs
208
- end
208
+ dependency.all_sources.each {|s| idx.add_source(s.specs) }
209
209
  end
210
210
  else
211
- @index
211
+ @index_requirements[:global]
212
212
  end
213
213
  end
214
214
 
215
+ def results_for(dependency, base)
216
+ index_for(dependency).search(dependency, base)
217
+ end
218
+
215
219
  def name_for(dependency)
216
220
  dependency.name
217
221
  end
@@ -239,18 +243,20 @@ module Bundler
239
243
  def relevant_sources_for_vertex(vertex)
240
244
  if vertex.root?
241
245
  [@source_requirements[vertex.name]]
242
- elsif @lockfile_uses_separate_rubygems_sources
246
+ elsif @no_aggregate_global_source
243
247
  vertex.recursive_predecessors.map do |v|
244
248
  @source_requirements[v.name]
245
- end << @source_requirements[:default]
249
+ end.compact << @source_requirements[:default]
250
+ else
251
+ []
246
252
  end
247
253
  end
248
254
 
249
255
  def sort_dependencies(dependencies, activated, conflicts)
250
256
  dependencies.sort_by do |dependency|
251
- dependency.all_sources = relevant_sources_for_vertex(activated.vertex_named(dependency.name))
252
257
  name = name_for(dependency)
253
258
  vertex = activated.vertex_named(name)
259
+ dependency.all_sources = relevant_sources_for_vertex(vertex)
254
260
  [
255
261
  @base_dg.vertex_named(name) ? 0 : 1,
256
262
  vertex.payload ? 0 : 1,
@@ -317,7 +323,7 @@ module Bundler
317
323
  "If you are updating multiple gems in your Gemfile at once,\n" \
318
324
  "try passing them all to `bundle update`"
319
325
  elsif source = @source_requirements[name]
320
- specs = source.specs[name]
326
+ specs = source.specs.search(name)
321
327
  versions_with_platforms = specs.map {|s| [s.version, s.platform] }
322
328
  message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
323
329
  message << if versions_with_platforms.any?
@@ -326,7 +332,7 @@ module Bundler
326
332
  "The source does not contain any versions of '#{name}'"
327
333
  end
328
334
  else
329
- message = "Could not find gem '#{requirement}' in any of the gem sources " \
335
+ message = "Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in any of the gem sources " \
330
336
  "listed in your Gemfile#{cache_message}."
331
337
  end
332
338
  raise GemNotFound, message
@@ -392,7 +398,7 @@ module Bundler
392
398
  if other_bundler_required
393
399
  o << "\n\n"
394
400
 
395
- candidate_specs = @source_requirements[:default_bundler].specs.search(conflict_dependency)
401
+ candidate_specs = @index_requirements[:default_bundler].search(conflict_dependency)
396
402
  if candidate_specs.any?
397
403
  target_version = candidate_specs.last.version
398
404
  new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
@@ -411,14 +417,8 @@ module Bundler
411
417
 
412
418
  relevant_sources = if conflict.requirement.source
413
419
  [conflict.requirement.source]
414
- elsif conflict.requirement.all_sources
415
- conflict.requirement.all_sources
416
- elsif @lockfile_uses_separate_rubygems_sources
417
- # every conflict should have an explicit group of sources when we
418
- # enforce strict pinning
419
- raise "no source set for #{conflict}"
420
420
  else
421
- []
421
+ conflict.requirement.all_sources
422
422
  end.compact.map(&:to_s).uniq.sort
423
423
 
424
424
  metadata_requirement = name.end_with?("\0")
@@ -455,23 +455,21 @@ module Bundler
455
455
  def validate_resolved_specs!(resolved_specs)
456
456
  resolved_specs.each do |v|
457
457
  name = v.name
458
- next unless sources = relevant_sources_for_vertex(v)
459
- sources.compact!
458
+ sources = relevant_sources_for_vertex(v)
459
+ next unless sources.any?
460
460
  if default_index = sources.index(@source_requirements[:default])
461
461
  sources.delete_at(default_index)
462
462
  end
463
- sources.reject! {|s| s.specs[name].empty? }
463
+ sources.reject! {|s| s.specs.search(name).empty? }
464
464
  sources.uniq!
465
465
  next if sources.size <= 1
466
466
 
467
- multisource_disabled = Bundler.feature_flag.disable_multisource?
468
-
469
467
  msg = ["The gem '#{name}' was found in multiple relevant sources."]
470
468
  msg.concat sources.map {|s| " * #{s}" }.sort
471
- msg << "You #{multisource_disabled ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
469
+ msg << "You #{@no_aggregate_global_source ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
472
470
  msg = msg.join("\n")
473
471
 
474
- raise SecurityError, msg if multisource_disabled
472
+ raise SecurityError, msg if @no_aggregate_global_source
475
473
  Bundler.ui.warn "Warning: #{msg}"
476
474
  end
477
475
  end
@@ -5,15 +5,19 @@ module Bundler
5
5
  attr_reader :path_sources,
6
6
  :git_sources,
7
7
  :plugin_sources,
8
- :global_rubygems_source,
8
+ :global_path_source,
9
9
  :metadata_source
10
10
 
11
+ def global_rubygems_source
12
+ @global_rubygems_source ||= rubygems_aggregate_class.new
13
+ end
14
+
11
15
  def initialize
12
16
  @path_sources = []
13
17
  @git_sources = []
14
18
  @plugin_sources = []
15
19
  @global_rubygems_source = nil
16
- @rubygems_aggregate = rubygems_aggregate_class.new
20
+ @global_path_source = nil
17
21
  @rubygems_sources = []
18
22
  @metadata_source = Source::Metadata.new
19
23
  end
@@ -22,7 +26,9 @@ module Bundler
22
26
  if options["gemspec"]
23
27
  add_source_to_list Source::Gemspec.new(options), path_sources
24
28
  else
25
- add_source_to_list Source::Path.new(options), path_sources
29
+ path_source = add_source_to_list Source::Path.new(options), path_sources
30
+ @global_path_source ||= path_source if options["global"]
31
+ path_source
26
32
  end
27
33
  end
28
34
 
@@ -41,24 +47,20 @@ module Bundler
41
47
  end
42
48
 
43
49
  def global_rubygems_source=(uri)
44
- if Bundler.feature_flag.disable_multisource?
45
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
46
- end
47
- add_rubygems_remote(uri)
50
+ @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
48
51
  end
49
52
 
50
53
  def add_rubygems_remote(uri)
51
- return if Bundler.feature_flag.disable_multisource?
52
- @rubygems_aggregate.add_remote(uri)
53
- @rubygems_aggregate
54
+ global_rubygems_source.add_remote(uri)
55
+ global_rubygems_source
54
56
  end
55
57
 
56
58
  def default_source
57
- global_rubygems_source || @rubygems_aggregate
59
+ global_path_source || global_rubygems_source
58
60
  end
59
61
 
60
62
  def rubygems_sources
61
- @rubygems_sources + [default_source]
63
+ @rubygems_sources + [global_rubygems_source]
62
64
  end
63
65
 
64
66
  def rubygems_remotes
@@ -94,10 +96,9 @@ module Bundler
94
96
 
95
97
  replacement_rubygems = !Bundler.feature_flag.disable_multisource? &&
96
98
  replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
97
- @rubygems_aggregate = replacement_rubygems if replacement_rubygems
99
+ @global_rubygems_source = replacement_rubygems if replacement_rubygems
98
100
 
99
101
  return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
100
- return true if replacement_rubygems && rubygems_remotes.sort_by(&:to_s) != replacement_rubygems.remotes.sort_by(&:to_s)
101
102
 
102
103
  false
103
104
  end
@@ -110,10 +111,6 @@ module Bundler
110
111
  all_sources.each(&:remote!)
111
112
  end
112
113
 
113
- def rubygems_primary_remotes
114
- @rubygems_aggregate.remotes
115
- end
116
-
117
114
  private
118
115
 
119
116
  def rubygems_aggregate_class
@@ -29,19 +29,21 @@ TODO: Write usage instructions here
29
29
  After checking out the repo, run `bin/setup` to install dependencies.<% if config[:test] %> Then, run `rake <%= config[:test].sub('mini', '').sub('rspec', 'spec') %>` to run the tests.<% end %> You can also run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the gem in this directory, ignoring other installed copies of this gem.<% end %>
30
30
 
31
31
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+ <% if config[:git] -%>
32
33
 
33
34
  ## Contributing
34
35
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).<% end %>
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/<%= config[:git_default_branch] %>/CODE_OF_CONDUCT.md).<% end %>
37
+ <% end -%>
36
38
  <% if config[:mit] -%>
37
39
 
38
40
  ## License
39
41
 
40
42
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
41
43
  <% end -%>
42
- <% if config[:coc] -%>
44
+ <% if config[:git] && config[:coc] -%>
43
45
 
44
46
  ## Code of Conduct
45
47
 
46
- Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).
48
+ Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/<%= config[:git_default_branch] %>/CODE_OF_CONDUCT.md).
47
49
  <% end -%>
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.2.12".freeze
4
+ VERSION = "2.2.13".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.12
4
+ version: 2.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -22,7 +22,7 @@ authors:
22
22
  autorequire:
23
23
  bindir: exe
24
24
  cert_chain: []
25
- date: 2021-03-01 00:00:00.000000000 Z
25
+ date: 2021-03-03 00:00:00.000000000 Z
26
26
  dependencies: []
27
27
  description: Bundler manages an application's dependencies through its entire life,
28
28
  across many machines, systematically and repeatably
@@ -352,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
352
352
  - !ruby/object:Gem::Version
353
353
  version: 2.5.2
354
354
  requirements: []
355
- rubygems_version: 3.2.12
355
+ rubygems_version: 3.2.13
356
356
  signing_key:
357
357
  specification_version: 4
358
358
  summary: The best way to manage your application's dependencies