cleanup: smarter gem handling

This commit is contained in:
Bo Anderson 2023-11-07 22:28:03 +00:00
parent 3baec056e7
commit 5c819100fe
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65

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|