Skip to content

Commit 95f72a4

Browse files
hsbtk0kubun
authored andcommitted
Merge RubyGems-3.5.17 and Bundler-2.5.17
1 parent d896641 commit 95f72a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1237
-737
lines changed

lib/bundler/cli.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def cli_help
110110
default_task(Bundler.feature_flag.default_cli_command)
111111

112112
class_option "no-color", type: :boolean, desc: "Disable colorization in output"
113-
class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
114-
desc: "Specify the number of times you wish to attempt network commands"
113+
class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
114+
desc: "Specify the number of times you wish to attempt network commands"
115115
class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
116116

117117
def help(cli = nil)
@@ -260,15 +260,15 @@ def install
260260
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
261261
method_option "group", aliases: "-g", type: :array, banner: "Update a specific group"
262262
method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
263-
method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
264-
method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
263+
method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
264+
method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
265265
method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
266266
method_option "redownload", type: :boolean, aliases: "--force", banner: "Force downloading every gem."
267267
method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
268268
method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
269-
method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
270-
method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
271-
method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
269+
method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
270+
method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
271+
method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
272272
method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
273273
method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
274274
method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
@@ -397,11 +397,11 @@ def fund
397397
end
398398

399399
desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
400-
method_option "all", type: :boolean,
401-
default: Bundler.feature_flag.cache_all?,
402-
banner: "Include all sources (including path and git)."
400+
method_option "all", type: :boolean,
401+
default: Bundler.feature_flag.cache_all?,
402+
banner: "Include all sources (including path and git)."
403403
method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
404-
method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
404+
method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
405405
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
406406
method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
407407
method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
@@ -605,7 +605,7 @@ def platform
605605
end
606606

607607
desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
608-
method_option "source", type: :string, banner: "Install gem from the given source"
608+
method_option "source", type: :string, banner: "Install gem from the given source"
609609
method_option "group", type: :string, banner: "Install gem into a bundler group"
610610
def inject(name, version)
611611
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
@@ -615,16 +615,16 @@ def inject(name, version)
615615

616616
desc "lock", "Creates a lockfile without installing"
617617
method_option "update", type: :array, lazy_default: true, banner: "ignore the existing lockfile, update all gems by default, or update list of given gems"
618-
method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
619-
method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
618+
method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
619+
method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
620620
method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
621621
method_option "lockfile", type: :string, default: nil, banner: "the path the lockfile should be written to"
622622
method_option "full-index", type: :boolean, default: false, banner: "Fall back to using the single-file index of all gems"
623623
method_option "add-platform", type: :array, default: [], banner: "Add a new platform to the lockfile"
624-
method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
625-
method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
626-
method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
627-
method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
624+
method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
625+
method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
626+
method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
627+
method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
628628
method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
629629
method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
630630
method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"

lib/bundler/cli/check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run
1717
begin
1818
definition.resolve_only_locally!
1919
not_installed = definition.missing_specs
20-
rescue GemNotFound, SolveFailure
20+
rescue GemNotFound, GitError, SolveFailure
2121
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
2222
Bundler.ui.warn "Install missing gems with `bundle install`."
2323
exit 1

lib/bundler/cli/gem.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def run
7979
ensure_safe_gem_name(name, constant_array)
8080

8181
templates = {
82-
"#{Bundler.preferred_gemfile_name}.tt" => Bundler.preferred_gemfile_name,
82+
"Gemfile.tt" => Bundler.preferred_gemfile_name,
8383
"lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
8484
"lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
8585
"sig/newgem.rbs.tt" => "sig/#{namespaced_path}.rbs",

lib/bundler/definition.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
115115
@originally_locked_specs = @locked_specs
116116
@locked_sources = []
117117
@locked_platforms = []
118-
@locked_checksums = nil
118+
@locked_checksums = Bundler.feature_flag.bundler_3_mode?
119119
end
120120

121121
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
@@ -137,7 +137,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
137137
end
138138
@unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
139139

140-
add_current_platform unless Bundler.frozen_bundle?
140+
@current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
141141

142142
converge_path_sources_to_gemspec_sources
143143
@path_changes = converge_paths
@@ -484,6 +484,7 @@ def nothing_changed?
484484

485485
!@source_changes &&
486486
!@dependency_changes &&
487+
!@current_platform_missing &&
487488
@new_platforms.empty? &&
488489
!@path_changes &&
489490
!@local_changes &&
@@ -629,6 +630,7 @@ def materialize(dependencies)
629630
def start_resolution
630631
local_platform_needed_for_resolvability = @most_specific_non_local_locked_ruby_platform && !@platforms.include?(local_platform)
631632
@platforms << local_platform if local_platform_needed_for_resolvability
633+
add_platform(Gem::Platform::RUBY) if RUBY_ENGINE == "truffleruby"
632634

633635
result = SpecSet.new(resolver.start)
634636

@@ -671,19 +673,19 @@ def current_platform_locked?
671673
end
672674

673675
def add_current_platform
674-
@most_specific_non_local_locked_ruby_platform = find_most_specific_non_local_locked_ruby_platform
676+
return if @platforms.include?(local_platform)
677+
678+
@most_specific_non_local_locked_ruby_platform = find_most_specific_locked_ruby_platform
675679
return if @most_specific_non_local_locked_ruby_platform
676680

677-
add_platform(local_platform)
681+
@platforms << local_platform
682+
true
678683
end
679684

680-
def find_most_specific_non_local_locked_ruby_platform
685+
def find_most_specific_locked_ruby_platform
681686
return unless generic_local_platform_is_ruby? && current_platform_locked?
682687

683-
most_specific_locked_ruby_platform = most_specific_locked_platform
684-
return unless most_specific_locked_ruby_platform != local_platform
685-
686-
most_specific_locked_ruby_platform
688+
most_specific_locked_platform
687689
end
688690

689691
def change_reason
@@ -705,6 +707,7 @@ def change_reason
705707
[
706708
[@source_changes, "the list of sources changed"],
707709
[@dependency_changes, "the dependencies in your gemfile changed"],
710+
[@current_platform_missing, "your lockfile does not include the current platform"],
708711
[@new_platforms.any?, "you added a new platform to your gemfile"],
709712
[@path_changes, "the gemspecs for path gems changed"],
710713
[@local_changes, "the gemspecs for git local gems changed"],

lib/bundler/force_platform.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
module Bundler
44
module ForcePlatform
5-
private
6-
75
# The `:force_ruby_platform` value used by dependencies for resolution, and
86
# by locked specifications for materialization is `false` by default, except
97
# for TruffleRuby. TruffleRuby generally needs to force the RUBY platform

lib/bundler/plugin/api/source.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def cache(spec, custom_path = nil)
196196

197197
FileUtils.rm_rf(new_cache_path)
198198
FileUtils.cp_r(install_path, new_cache_path)
199+
FileUtils.rm_rf(app_cache_path.join(".git"))
199200
FileUtils.touch(app_cache_path.join(".bundlecache"))
200201
end
201202

lib/bundler/rubygems_ext.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,20 @@ class Dependency
237237

238238
include ::Bundler::ForcePlatform
239239

240+
attr_reader :force_ruby_platform
241+
240242
attr_accessor :source, :groups
241243

242244
alias_method :eql?, :==
243245

244-
def force_ruby_platform
245-
return @force_ruby_platform if defined?(@force_ruby_platform) && !@force_ruby_platform.nil?
246-
247-
@force_ruby_platform = default_force_ruby_platform
248-
end
249-
250-
def encode_with(coder)
251-
to_yaml_properties.each do |ivar|
252-
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
246+
unless method_defined?(:encode_with, false)
247+
def encode_with(coder)
248+
[:@name, :@requirement, :@type, :@prerelease, :@version_requirements].each do |ivar|
249+
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
250+
end
253251
end
254252
end
255253

256-
def to_yaml_properties
257-
instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
258-
end
259-
260254
def to_lock
261255
out = String.new(" #{name}")
262256
unless requirement.none?

lib/bundler/runtime.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ def cache(custom_path = nil, local = false)
128128
spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
129129
end
130130

131-
Dir[cache_path.join("*/.git")].each do |git_dir|
132-
FileUtils.rm_rf(git_dir)
133-
FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
134-
end
135-
136131
prune_cache(cache_path) unless Bundler.settings[:no_prune]
137132
end
138133

lib/bundler/source/git.rb

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def local_override!(path)
164164
"does not exist. Run `bundle config unset local.#{override_for(original_path)}` to remove the local override"
165165
end
166166

167-
set_local!(path)
167+
@local = true
168+
set_paths!(path)
168169

169170
# Create a new git proxy without the cached revision
170171
# so the Gemfile.lock always picks up the new revision.
@@ -187,13 +188,11 @@ def local_override!(path)
187188
end
188189

189190
def specs(*)
190-
set_local!(app_cache_path) if has_app_cache? && !local?
191+
set_cache_path!(app_cache_path) if has_app_cache? && !local?
191192

192193
if requires_checkout? && !@copied
193194
fetch
194-
git_proxy.copy_to(install_path, submodules)
195-
serialize_gemspecs_in(install_path)
196-
@copied = true
195+
checkout
197196
end
198197

199198
local_specs
@@ -206,10 +205,7 @@ def install(spec, options = {})
206205
print_using_message "Using #{version_message(spec, options[:previous_spec])} from #{self}"
207206

208207
if (requires_checkout? && !@copied) || force
209-
Bundler.ui.debug " * Checking out revision: #{ref}"
210-
git_proxy.copy_to(install_path, submodules)
211-
serialize_gemspecs_in(install_path)
212-
@copied = true
208+
checkout
213209
end
214210

215211
generate_bin_options = { disable_extensions: !Bundler.rubygems.spec_missing_extensions?(spec), build_args: options[:build_args] }
@@ -221,12 +217,13 @@ def install(spec, options = {})
221217
def cache(spec, custom_path = nil)
222218
app_cache_path = app_cache_path(custom_path)
223219
return unless Bundler.feature_flag.cache_all?
224-
return if path == app_cache_path
220+
return if install_path == app_cache_path
221+
return if cache_path == app_cache_path
225222
cached!
226223
FileUtils.rm_rf(app_cache_path)
227224
git_proxy.checkout if requires_checkout?
228-
git_proxy.copy_to(app_cache_path, @submodules)
229-
serialize_gemspecs_in(app_cache_path)
225+
FileUtils.cp_r("#{cache_path}/.", app_cache_path)
226+
FileUtils.touch(app_cache_path.join(".bundlecache"))
230227
end
231228

232229
def load_spec_files
@@ -270,6 +267,13 @@ def local?
270267

271268
private
272269

270+
def checkout
271+
Bundler.ui.debug " * Checking out revision: #{ref}"
272+
git_proxy.copy_to(install_path, submodules)
273+
serialize_gemspecs_in(install_path)
274+
@copied = true
275+
end
276+
273277
def humanized_ref
274278
if local?
275279
path
@@ -298,10 +302,19 @@ def serialize_gemspecs_in(destination)
298302
end
299303
end
300304

301-
def set_local!(path)
302-
@local = true
303-
@local_specs = @git_proxy = nil
304-
@cache_path = @install_path = path
305+
def set_paths!(path)
306+
set_cache_path!(path)
307+
set_install_path!(path)
308+
end
309+
310+
def set_cache_path!(path)
311+
@git_proxy = nil
312+
@cache_path = path
313+
end
314+
315+
def set_install_path!(path)
316+
@local_specs = nil
317+
@install_path = path
305318
end
306319

307320
def has_app_cache?

lib/bundler/spec_set.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def []=(key, value)
9494
end
9595

9696
def delete(specs)
97-
specs.each {|spec| @specs.delete(spec) }
97+
Array(specs).each {|spec| @specs.delete(spec) }
9898

9999
reset!
100100
end
@@ -280,7 +280,7 @@ def specs_for_dependency(dep, platform)
280280
if platform
281281
GemHelpers.select_best_platform_match(specs_for_name, platform, force_ruby: dep.force_ruby_platform)
282282
else
283-
GemHelpers.select_best_local_platform_match(specs_for_name, force_ruby: dep.force_ruby_platform)
283+
GemHelpers.select_best_local_platform_match(specs_for_name, force_ruby: dep.force_ruby_platform || dep.default_force_ruby_platform)
284284
end
285285
end
286286

0 commit comments

Comments
 (0)