Skip to content
Merged
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
12 changes: 6 additions & 6 deletions HyperWindow/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ func isTrusted(prompt: Bool) -> Bool {
}


func formattedVersion(shortVersion: String, bundleVersion: String, short: Bool = false) -> String {
short ? shortVersion : "\(shortVersion) (\(bundleVersion))"
}

func appVersion(short: Bool = false) -> String {
let shortVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "-"
if short {
return shortVersion
} else {
let bundleVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "-"
return "\(shortVersion) (\(bundleVersion))"
}
let bundleVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "-"
return formattedVersion(shortVersion: shortVersion, bundleVersion: bundleVersion, short: short)
}

func settingsVersion(infoDictionary: [String: Any] = Bundle.main.infoDictionary ?? [:]) -> String {
Expand Down
5 changes: 5 additions & 0 deletions HyperWindowTests/PreferencesControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ final class PreferencesControllerTests: XCTestCase {
XCTAssertTrue(controls.allSatisfy { contentView.convert($0.bounds, from: $0).maxX <= contentView.bounds.maxX })
}

func testFormattedVersionFormatsShortAndFullVersions() {
XCTAssertEqual(formattedVersion(shortVersion: "1.2.3", bundleVersion: "42", short: true), "1.2.3")
XCTAssertEqual(formattedVersion(shortVersion: "1.2.3", bundleVersion: "42"), "1.2.3 (42)")
}

func testSettingsVersionIncludesCommitForUntaggedBuild() {
let version = settingsVersion(infoDictionary: [
"CFBundleShortVersionString": "1.2.3",
Expand Down