File tree Expand file tree Collapse file tree
Sources/XcodesKit/Services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ public struct XcodeListPresentationService: Sendable {
4545 )
4646 : availableXcodes)
4747 . matchingArchitectureFilters ( architectures)
48- let visibleAvailableXcodes = XcodeListService . filteringPrereleasesWithDuplicateBuildMetadata ( adjustedAvailableXcodes)
48+ let visibleAvailableXcodes = Self . filteringPrereleasesWithReleaseMatchingBuildAndArchitecture ( adjustedAvailableXcodes)
4949
5050 let adjustedInstalledXcodes = architectures. isEmpty
5151 ? installedXcodes
@@ -149,4 +149,18 @@ public struct XcodeListPresentationService: Sendable {
149149 guard let selectedXcodePath else { return nil }
150150 return installedXcodes. first { selectedXcodePath. hasPrefix ( $0. path. string) }
151151 }
152+
153+ static func filteringPrereleasesWithReleaseMatchingBuildAndArchitecture( _ xcodes: [ AvailableXcode ] ) -> [ AvailableXcode ] {
154+ xcodes. filter { availableXcode in
155+ let releaseWithSameBuildAndArchitecture = xcodes. contains {
156+ $0. version. buildMetadataIdentifiers == availableXcode. version. buildMetadataIdentifiers &&
157+ $0. version. prereleaseIdentifiers. isEmpty &&
158+ $0. architectures == availableXcode. architectures
159+ }
160+
161+ return availableXcode. version. prereleaseIdentifiers. isEmpty ||
162+ availableXcode. version. buildMetadataIdentifiers. isEmpty ||
163+ !releaseWithSameBuildAndArchitecture
164+ }
165+ }
152166}
Original file line number Diff line number Diff line change @@ -220,14 +220,9 @@ public struct XcodeListService: Sendable {
220220 $0. version. buildMetadataIdentifiers == availableXcode. version. buildMetadataIdentifiers
221221 }
222222
223- let releaseWithSameBuildAndArchitecture = availableXcodesWithIdenticalBuildIdentifiers. contains {
224- $0. version. prereleaseIdentifiers. isEmpty &&
225- $0. architectures == availableXcode. architectures
226- }
227-
228223 return availableXcodesWithIdenticalBuildIdentifiers. count == 1 ||
229224 availableXcodesWithIdenticalBuildIdentifiers. count > 1 &&
230- ( availableXcode. version. prereleaseIdentifiers. isEmpty || !releaseWithSameBuildAndArchitecture )
225+ ( availableXcode. version. prereleaseIdentifiers. isEmpty || availableXcode . architectures ? . isEmpty == false )
231226 }
232227 }
233228
Original file line number Diff line number Diff line change @@ -1102,7 +1102,7 @@ final class XcodesKitTests: XCTestCase {
11021102 ] )
11031103 }
11041104
1105- func testXcodeListServiceFiltersArchitectureSpecificPrereleaseWhenReleaseHasSameArchitecture ( ) throws {
1105+ func testXcodeListServiceKeepsArchitectureSpecificPrereleaseWhenReleaseHasSameArchitecture ( ) throws {
11061106 let release = AvailableXcode (
11071107 version: try XCTUnwrap ( Version ( " 26.5.0+17F42 " ) ) ,
11081108 url: try XCTUnwrap ( URL ( string: " https://apple.com/xcode-arm64.xip " ) ) ,
@@ -1124,7 +1124,8 @@ final class XcodesKitTests: XCTestCase {
11241124 ] )
11251125
11261126 XCTAssertEqual ( filtered. map ( \. xcodeID) , [
1127- release. xcodeID
1127+ release. xcodeID,
1128+ prerelease. xcodeID
11281129 ] )
11291130 }
11301131
You can’t perform that action at this time.
0 commit comments