Merge pull request #16193 from Bo98/smarter-gem-cleanup

cleanup: smarter gem handling
This commit is contained in:
Bo Anderson 2023-11-08 17:34:23 +00:00 committed by GitHub
commit ae64469d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -480,11 +480,24 @@ module Homebrew
return if portable_rubies_to_remove.empty?
bundler_path = vendor_dir/"bundle/ruby"
if dry_run?
puts Utils.popen_read("git", "-C", HOMEBREW_REPOSITORY, "clean", "-nx", bundler_path).chomp
else
puts Utils.popen_read("git", "-C", HOMEBREW_REPOSITORY, "clean", "-ffqx", bundler_path).chomp
bundler_paths = (vendor_dir/"bundle/ruby").children.select do |child|
basename = child.basename.to_s
next false if basename == ".homebrew_gem_groups"
next true unless child.directory?
[
"#{Version.new(portable_ruby_latest_version).major_minor}.0",
RbConfig::CONFIG["ruby_version"],
].uniq.exclude?(basename)
end
bundler_paths.each do |bundler_path|
if dry_run?
puts Utils.popen_read("git", "-C", HOMEBREW_REPOSITORY, "clean", "-nx", bundler_path).chomp
else
puts Utils.popen_read("git", "-C", HOMEBREW_REPOSITORY, "clean", "-ffqx", bundler_path).chomp
end
end
portable_rubies_to_remove.each do |portable_ruby|