Merge pull request #58 from RobotsAndPencils/build-identifiers-in-ui

Always show build identifiers in list and info pane
This commit is contained in:
Brandon Evans 2021-01-16 13:36:11 -07:00 committed by GitHub
commit 808dd022ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 12 deletions

View file

@ -411,7 +411,7 @@ public enum InstallationError: LocalizedError, Equatable {
case .missingSudoerPassword:
return "Missing password. Please try again."
case let .unavailableVersion(version):
return "Could not find version \(version.xcodeDescription)."
return "Could not find version \(version.appleDescription)."
case .noNonPrereleaseVersionAvailable:
return "No non-prerelease versions available."
case .noPrereleaseVersionAvailable:
@ -419,11 +419,11 @@ public enum InstallationError: LocalizedError, Equatable {
case .missingUsernameOrPassword:
return "Missing username or a password. Please try again."
case let .versionAlreadyInstalled(installedXcode):
return "\(installedXcode.version.xcodeDescription) is already installed at \(installedXcode.path)"
return "\(installedXcode.version.appleDescription) is already installed at \(installedXcode.path)"
case let .invalidVersion(version):
return "\(version) is not a valid version number."
case let .versionNotInstalled(version):
return "\(version.xcodeDescription) is not installed."
return "\(version.appleDescription) is not installed."
}
}
}

View file

@ -38,7 +38,12 @@ public extension Version {
self = Version(major: major, minor: minor, patch: patch, prereleaseIdentifiers: prereleaseIdentifiers, buildMetadataIdentifiers: [buildMetadataIdentifier].compactMap { $0 })
}
var xcodeDescription: String {
/// The intent here is to match Apple's marketing version
///
/// Only show the patch number if it's not 0
/// Format prerelease identifiers
/// Don't include build identifiers
var appleDescription: String {
var base = "\(major).\(minor)"
if patch != 0 {
base += ".\(patch)"
@ -47,10 +52,6 @@ public extension Version {
base += " " + prereleaseIdentifiers
.map { $0.replacingOccurrences(of: "-", with: " ").capitalized.replacingOccurrences(of: "Gm", with: "GM") }
.joined(separator: " ")
if !buildMetadataIdentifiers.isEmpty {
base += " (\(buildMetadataIdentifiers.joined(separator: " ")))"
}
}
return base
}

View file

@ -37,6 +37,6 @@ struct Xcode: Identifiable, CustomStringConvertible {
var id: Version { version }
var description: String {
version.xcodeDescription
version.appleDescription
}
}

View file

@ -17,7 +17,7 @@ struct InfoPane: View {
icon(for: xcode)
VStack(alignment: .leading) {
Text("Xcode \(xcode.description)")
Text(verbatim: "Xcode \(xcode.description) (\(xcode.version.buildMetadataIdentifiers.joined(separator: " ")))")
.font(.title)
.frame(maxWidth: .infinity, alignment: .leading)

View file

@ -11,8 +11,8 @@ struct XcodeListViewRow: View {
HStack {
appIconView(for: xcode)
VStack(alignment: .leading) {
Text(xcode.description)
VStack(alignment: .leading) {
Text(verbatim: "\(xcode.description) (\(xcode.version.buildMetadataIdentifiers.joined(separator: " ")))")
.font(.body)
if case let .installed(path) = xcode.installState {