strip the build-id suffix from cask version labels
Some casks (claude and others) version themselves as "user-facing-version,build-id" — the hash after the comma only feeds brew's own download URL and was never meant for display, but showed up verbatim in the Outdated menu. displayVersion() now truncates at the first comma for both the installed and target version shown in the label; brew commands are unaffected since they operate on the package name, never this string. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
210a8167b8
commit
af220a4ee6
|
|
@ -7,8 +7,15 @@ struct OutdatedPackage: Codable, Equatable {
|
|||
|
||||
/// Menu label, e.g. "wget 1.21 → 1.22"
|
||||
var label: String {
|
||||
let installed = installedVersions.joined(separator: ", ")
|
||||
return "\(name) \(installed) → \(currentVersion)"
|
||||
let installed = installedVersions.map(Self.displayVersion).joined(separator: ", ")
|
||||
return "\(name) \(installed) → \(Self.displayVersion(currentVersion))"
|
||||
}
|
||||
|
||||
/// Some casks (e.g. claude: "1.20186.9,69f150a4c9…") version themselves
|
||||
/// as "user-facing-version,build-id" — the part after the comma only
|
||||
/// matters for brew's own download URL, never for display.
|
||||
static func displayVersion(_ version: String) -> String {
|
||||
String(version.split(separator: ",", maxSplits: 1)[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,15 @@ final class BrewParserTests: XCTestCase {
|
|||
XCTAssertEqual(package.label, "wget 1.21.3 → 1.21.4")
|
||||
}
|
||||
|
||||
func testParseOutdatedJSON_packageLabel_stripsBuildIdAfterComma() {
|
||||
let package = OutdatedPackage(
|
||||
name: "claude",
|
||||
installedVersions: ["1.20185.0,5e8f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f"],
|
||||
currentVersion: "1.20186.9,69f150a4c9316d5c8cd7b9f130ed583d15c0383e"
|
||||
)
|
||||
XCTAssertEqual(package.label, "claude 1.20185.0 → 1.20186.9")
|
||||
}
|
||||
|
||||
// MARK: - parseVersion
|
||||
|
||||
func testParseVersion_picksFirstLine() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue