Skip to content

Commit

Permalink
Merge pull request #18737 from Homebrew/prefer-newest-xcode
Browse files Browse the repository at this point in the history
os/mac: prefer newest Xcode when searching using `mdfind`
  • Loading branch information
carlocab authored Nov 8, 2024
2 parents a8a4c07 + 09fc836 commit 025d1c7
Showing 1 changed file with 9 additions and 4 deletions.
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 @@ def self.macports_or_fink

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"

paths = mdfind(*ids).filter_map do |bundle_path|
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") }
end

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

0 comments on commit 025d1c7

Please sign in to comment.