Skip to content
Merged
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
15 changes: 12 additions & 3 deletions macos/Sources/Features/Worktrunk/WorktrunkInstaller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ enum WorktrunkInstallerError: LocalizedError {

enum WorktrunkInstaller {
private struct Release {
static let version = "0.22.0"
static let version = "0.27.0"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reinstall pinned worktrunk when an older binary exists

Updating Release.version to 0.27.0 does not actually upgrade existing installs because installPinnedWorktrunkIfNeeded() still exits as soon as wt and git-wt are present (WorktrunkInstaller.swift:50-52), without checking their version. In the common upgrade path (user already has 0.22.0 installed), this leaves stale binaries in place, so the new pinned version is never applied and any 0.27.0-dependent behavior will not take effect.

Useful? React with 👍 / 👎.

static let assetName = "worktrunk-aarch64-apple-darwin.tar.xz"
static let sha256 = "1fd193d8ed95453dbeadd900035312a6df61ff3fad43dc85eb1a9f7b48895b3c"
static let sha256 = "3ebfbe6b034afeb686bbddd39c0bee1942ed1448a7a7d5c9cca703ae9693683f"

static var url: URL {
URL(string: "https://github.com/max-sixty/worktrunk/releases/download/v\(version)/\(assetName)")!
Expand All @@ -47,8 +47,11 @@ enum WorktrunkInstaller {
let binDir = AgentStatusPaths.binDir
let wtDest = binDir.appendingPathComponent("wt", isDirectory: false)
let gitWtDest = binDir.appendingPathComponent("git-wt", isDirectory: false)
let versionFile = binDir.appendingPathComponent(".worktrunk-version", isDirectory: false)

if FileManager.default.isExecutableFile(atPath: wtDest.path),
FileManager.default.isExecutableFile(atPath: gitWtDest.path) {
FileManager.default.isExecutableFile(atPath: gitWtDest.path),
installedVersion(at: versionFile) == Release.version {
return
}

Expand Down Expand Up @@ -96,6 +99,12 @@ enum WorktrunkInstaller {
try makeExecutable(url: gitWtDest)
_ = try? removeQuarantine(url: wtDest)
_ = try? removeQuarantine(url: gitWtDest)

try? Release.version.write(to: versionFile, atomically: true, encoding: .utf8)
}

private static func installedVersion(at url: URL) -> String? {
try? String(contentsOf: url, encoding: .utf8).trimmingCharacters(in: .whitespacesAndNewlines)
}

private static func isSupportedArchitecture() -> Bool {
Expand Down
Loading