Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: smarter gem handling #16193

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 18 additions & 5 deletions Library/Homebrew/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,24 @@

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

Check warning on line 484 in Library/Homebrew/cleanup.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleanup.rb#L483-L484

Added lines #L483 - L484 were not covered by tests

next false if basename == ".homebrew_gem_groups"
next true unless child.directory?

[
"#{Version.new(portable_ruby_latest_version).major_minor}.0",

Check warning on line 490 in Library/Homebrew/cleanup.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleanup.rb#L490

Added line #L490 was not covered by tests
RbConfig::CONFIG["ruby_version"],
].uniq.exclude?(basename)
end

bundler_paths.each do |bundler_path|
if dry_run?

Check warning on line 496 in Library/Homebrew/cleanup.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cleanup.rb#L495-L496

Added lines #L495 - L496 were not covered by tests
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|
Expand Down