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

os/mac: prefer newest Xcode when searching using mdfind #18737

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Library/Homebrew/os/mac.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,15 @@

sig { params(ids: String).returns(T.nilable(Pathname)) }
def self.app_with_bundle_id(*ids)
path = mdfind(*ids)
.reject { |p| p.include?("/Backups.backupdb/") }
.first
Pathname.new(path) if path.present?
require "bundle_version"

Check warning on line 198 in Library/Homebrew/os/mac.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/mac.rb#L198

Added line #L198 was not covered by tests

paths = mdfind(*ids).filter_map do |bundle_path|

Check warning on line 200 in Library/Homebrew/os/mac.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/mac.rb#L200

Added line #L200 was not covered by tests
Pathname.new(bundle_path) if bundle_path.exclude?("/Backups.backupdb/")
end
return paths.first unless paths.all? { |bp| (bp/"Contents/Info.plist").exist? }

# Prefer newest one, if we can find it.
paths.max_by { |bundle_path| Homebrew::BundleVersion.from_info_plist(bundle_path/"Contents/Info.plist") }

Check warning on line 206 in Library/Homebrew/os/mac.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/os/mac.rb#L206

Added line #L206 was not covered by tests
end

sig { params(ids: String).returns(T::Array[String]) }
Expand Down
Loading