mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
This adds a new filter option that shows only releases, plus any betas that do not have a release version. So as of today (July 7, 2023 the Xcode 15 betas will be shown but the Xcode 14 betas won't. Note that this will also show betas for older Xcode versions if necessary, for example if an Xcode 14.3.2 beta is released it will be shown until the mainline Xcode 14.3.2 is released.
39 lines
1.9 KiB
Swift
39 lines
1.9 KiB
Swift
import Version
|
|
|
|
public extension Version {
|
|
/// Determines if two Xcode versions should be treated equivalently. This is not the same as equality.
|
|
///
|
|
/// We need a way to determine if two Xcode versions are the same without always having full information, and supporting different data sources.
|
|
/// For example, the Apple data source often doesn't have build metadata identifiers.
|
|
func isEquivalent(to other: Version) -> Bool {
|
|
// If we don't have build metadata identifiers for both Versions, compare major, minor, patch and prerelease identifiers.
|
|
if buildMetadataIdentifiers.isEmpty || other.buildMetadataIdentifiers.isEmpty {
|
|
return major == other.major &&
|
|
minor == other.minor &&
|
|
patch == other.patch &&
|
|
prereleaseIdentifiers.map { $0.lowercased() } == other.prereleaseIdentifiers.map { $0.lowercased() }
|
|
// If we have build metadata identifiers for both, we can ignore the prerelease identifiers.
|
|
} else {
|
|
return major == other.major &&
|
|
minor == other.minor &&
|
|
patch == other.patch &&
|
|
buildMetadataIdentifiers.map { $0.lowercased() } == other.buildMetadataIdentifiers.map { $0.lowercased() }
|
|
}
|
|
}
|
|
|
|
var descriptionWithoutBuildMetadata: String {
|
|
var base = "\(major).\(minor).\(patch)"
|
|
if !prereleaseIdentifiers.isEmpty {
|
|
base += "-" + prereleaseIdentifiers.joined(separator: ".")
|
|
}
|
|
return base
|
|
}
|
|
|
|
var isPrerelease: Bool { prereleaseIdentifiers.isEmpty == false }
|
|
var isNotPrerelease: Bool { prereleaseIdentifiers.isEmpty == true }
|
|
|
|
/// Returns a new Version instance without any `prereleaseIdentifiers` or `buildMetadataIdentifiers`
|
|
func withoutIdentifiers() -> Version {
|
|
Version(major, minor, patch)
|
|
}
|
|
}
|