mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-27 06:20:08 +01:00
👌 Correctly resolve tagged version (#195)
This commit is contained in:
@@ -18,4 +18,30 @@ class AppUpdaterCheckTest: XCTestCase {
|
|||||||
XCTAssertNotNil(version)
|
XCTAssertNotNil(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testTaggedReleaseOmitsZeroPatch() {
|
||||||
|
let version = AppVersion.from("3.5.0_333")!
|
||||||
|
|
||||||
|
XCTAssertEqual(version.tagged, "3.5")
|
||||||
|
XCTAssertEqual(version.version, "3.5.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testTaggedReleaseDoesntOmitNonZeroPatch() {
|
||||||
|
let version = AppVersion.from("3.5.1_333")!
|
||||||
|
|
||||||
|
XCTAssertEqual(version.tagged, "3.5.1")
|
||||||
|
XCTAssertEqual(version.version, "3.5.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testTagTruncationDoesntAffectMajorVersions() {
|
||||||
|
var version = AppVersion.from("5.0_333")!
|
||||||
|
|
||||||
|
XCTAssertEqual(version.tagged, "5.0")
|
||||||
|
XCTAssertEqual(version.version, "5.0")
|
||||||
|
|
||||||
|
version = AppVersion.from("5.0.0_333")!
|
||||||
|
|
||||||
|
XCTAssertEqual(version.tagged, "5.0")
|
||||||
|
XCTAssertEqual(version.version, "5.0.0")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,8 +146,9 @@ class AppUpdateChecker {
|
|||||||
text: "updater.alerts.buttons.release_notes".localized,
|
text: "updater.alerts.buttons.release_notes".localized,
|
||||||
action: { vc in
|
action: { vc in
|
||||||
vc.close(with: .OK)
|
vc.close(with: .OK)
|
||||||
|
|
||||||
NSWorkspace.shared.open(
|
NSWorkspace.shared.open(
|
||||||
Constants.Urls.GitHubReleases.appendingPathComponent("/tag/v\(version.version)\(devSuffix)")
|
Constants.Urls.GitHubReleases.appendingPathComponent("/tag/v\(version.tagged)\(devSuffix)")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ class AppVersion {
|
|||||||
return AppVersion.from("\(App.shortVersion)_\(App.bundleVersion)")!
|
return AppVersion.from("\(App.shortVersion)_\(App.bundleVersion)")!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tagged: String {
|
||||||
|
if version.suffix(2) == ".0" && version.count > 3 {
|
||||||
|
return String(version.dropLast(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|
||||||
var computerReadable: String {
|
var computerReadable: String {
|
||||||
return "\(version)_\(build ?? "0")"
|
return "\(version)_\(build ?? "0")"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user