mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Don't consider versions without build identifiers for identical builds
This commit is contained in:
parent
ef646b7b88
commit
b8bae4f32c
2 changed files with 33 additions and 1 deletions
|
|
@ -450,6 +450,9 @@ class AppState: ObservableObject {
|
|||
// Map all of the available versions into Xcode values that join available and installed Xcode data for display.
|
||||
var newAllXcodes = adjustedAvailableXcodes
|
||||
.filter { availableXcode in
|
||||
// If we don't have the build identifier, don't attempt to filter prerelease versions with identical build identifiers
|
||||
guard !availableXcode.version.buildMetadataIdentifiers.isEmpty else { return true }
|
||||
|
||||
let availableXcodesWithIdenticalBuildIdentifiers = availableXcodes
|
||||
.filter({ $0.version.buildMetadataIdentifiers == availableXcode.version.buildMetadataIdentifiers })
|
||||
|
||||
|
|
@ -466,7 +469,10 @@ class AppState: ObservableObject {
|
|||
let identicalBuilds: [Version]
|
||||
let prereleaseAvailableXcodesWithIdenticalBuildIdentifiers = availableXcodes
|
||||
.filter {
|
||||
$0.version.buildMetadataIdentifiers == availableXcode.version.buildMetadataIdentifiers && !$0.version.prereleaseIdentifiers.isEmpty
|
||||
return $0.version.buildMetadataIdentifiers == availableXcode.version.buildMetadataIdentifiers &&
|
||||
!$0.version.prereleaseIdentifiers.isEmpty &&
|
||||
// If we don't have the build identifier, don't consider this as a potential identical build
|
||||
!$0.version.buildMetadataIdentifiers.isEmpty
|
||||
}
|
||||
// If this is the release version, add the identical builds to it
|
||||
if !prereleaseAvailableXcodesWithIdenticalBuildIdentifiers.isEmpty, availableXcode.version.prereleaseIdentifiers.isEmpty {
|
||||
|
|
|
|||
|
|
@ -232,4 +232,30 @@ class AppStateUpdateTests: XCTestCase {
|
|||
XCTAssertEqual(subject.allXcodes.map(\.version), [Version("12.4.0+12D4e")!])
|
||||
XCTAssertEqual(subject.allXcodes.map(\.identicalBuilds), [[Version("12.4.0+12D4e")!, Version("12.4.0-RC+12D4e")!]])
|
||||
}
|
||||
|
||||
func testIdenticalBuilds_AppleDataSource_DoNotMergeVersionsWithoutBuildIdentifiers() {
|
||||
Current.defaults.string = { key in
|
||||
if key == "dataSource" {
|
||||
return "apple"
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
subject.allXcodes = [
|
||||
]
|
||||
|
||||
subject.updateAllXcodes(
|
||||
availableXcodes: [
|
||||
AvailableXcode(version: Version("12.4.0")!, url: URL(string: "https://apple.com/xcode.xip")!, filename: "mock.xip", releaseDate: nil),
|
||||
AvailableXcode(version: Version("12.3.0-RC")!, url: URL(string: "https://apple.com/xcode.xip")!, filename: "mock.xip", releaseDate: nil),
|
||||
],
|
||||
installedXcodes: [
|
||||
],
|
||||
selectedXcodePath: nil
|
||||
)
|
||||
|
||||
XCTAssertEqual(subject.allXcodes.map(\.version), [Version("12.4.0")!, Version("12.3.0-RC")!])
|
||||
XCTAssertEqual(subject.allXcodes.map(\.identicalBuilds), [[], []])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue