Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Xcodes/Backend/AppState+Install.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import XcodesLoginKit
/// Downloads and installs Xcodes
extension AppState {

static func installNotificationTitle(for version: Version) -> String {
version.appleDescription
}

// check to see if we should auto install for the user
public func autoInstallIfNeeded() {
guard let storageValue = Current.defaults.get(forKey: "autoInstallation") as? Int, let autoInstallType = AutoInstallationType(rawValue: storageValue) else { return }
Expand Down Expand Up @@ -471,7 +475,7 @@ extension AppState {

let xcode = allXcodes[index]
if postNotification {
Current.notificationManager.scheduleNotification(title: xcode.version.major.description + "." + xcode.version.appleDescription, body: step.description, category: .normal)
Current.notificationManager.scheduleNotification(title: AppState.installNotificationTitle(for: xcode.version), body: step.description, category: .normal)
}
}

Expand Down
16 changes: 16 additions & 0 deletions XcodesTests/AppStateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,22 @@ class AppStateTests: XCTestCase {
}
}

func test_InstallNotificationTitle_DoesNotDuplicateMajorVersion() {
XCTAssertEqual(
AppState.installNotificationTitle(for: Version(major: 27, minor: 0, patch: 0, prereleaseIdentifiers: ["beta", "4"])),
"27.0 Beta 4"
)
XCTAssertEqual(
AppState.installNotificationTitle(for: Version(major: 26, minor: 5, patch: 0)),
"26.5"
)
// Stable release with patch
XCTAssertEqual(
AppState.installNotificationTitle(for: Version(major: 10, minor: 2, patch: 1)),
"10.2.1"
)
}

private func recordAllXcodeInstallStates(during operation: () async throws -> Void) async throws -> [[XcodeInstallState]] {
var states: [[XcodeInstallState]] = []
var cancellable: AnyCancellable?
Expand Down