Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say when Homebrew belongs to another account of the Mac, and change nothing

Țugui Dragoșb9ba4bcec06b
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index d5799d08..5edf67ca 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -50602,6 +50602,112 @@
"comment" : "A product's name, never translated.",
"shouldTranslate" : false
},
+ "Homebrew Belongs to Another Account" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew patří jinému účtu"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew gehört einem anderen Benutzeraccount"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew pertenece a otra cuenta"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew appartient à un autre compte"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew appartiene a un altro account"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrewは別のアカウントのものです"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew가 다른 계정에 속해 있음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew hoort bij een andere account"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew należy do innego konta"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Homebrew Pertence a Outra Conta"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew aparține altui cont"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew принадлежит другой учетной записи"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew tillhör ett annat konto"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew Başka Bir Hesaba Ait"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew належить іншому обліковому запису"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew属于其他账户"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew屬於另一個帳號"
+ }
+ }
+ }
+ },
"Homebrew Has to Update First" : {
"localizations" : {
"cs" : {
@@ -55054,6 +55160,218 @@
}
}
},
+ "Homebrew on this Mac belongs to %@, so only that account can update or change it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew v tomto Macu patří účtu %@, takže ho může aktualizovat nebo měnit jen tento účet."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew auf diesem Mac gehört dem Benutzeraccount „%@“, daher kann nur dieser Benutzeraccount Homebrew aktualisieren oder ändern."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "El Homebrew de este Mac pertenece a %@, así que solo esa cuenta puede actualizarlo o modificarlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sur ce Mac, Homebrew appartient à %@ : seul ce compte peut donc le mettre à jour ou le modifier."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew su questo Mac appartiene all’account %@, quindi solo quell’account può aggiornarlo o modificarlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "このMacのHomebrewはアカウント“%@”のものであるため、アップデートや変更ができるのはそのアカウントだけです。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 Mac의 Homebrew는 ‘%@’ 계정에 속해 있으므로 해당 계정만 Homebrew를 업데이트하거나 변경할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew op deze Mac hoort bij de account '%@', dus alleen die account kan Homebrew bijwerken of wijzigen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew na tym Macu należy do konta %@, więc tylko to konto może go odświeżać lub zmieniać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Homebrew deste Mac pertence à conta %@, então só essa conta pode atualizá-lo ou alterá-lo."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew de pe acest Mac aparține contului %@, așa că doar acel cont îl poate actualiza sau modifica."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew на этом Mac принадлежит учетной записи «%@», поэтому обновлять или изменять его может только эта учетная запись."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew på den här datorn tillhör %@, så bara det kontot kan uppdatera eller ändra det."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bu Mac’teki Homebrew %@ hesabına ait, bu yüzden onu yalnızca o hesap güncelleyebilir veya değiştirebilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew на цьому Mac належить обліковому запису «%@», тож лише цей обліковий запис може оновлювати чи змінювати його."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "这台Mac上的Homebrew属于“%@”,因此只有该账户才能更新或更改它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "這部Mac上的Homebrew屬於「%@」,因此只有該帳號可以更新或更改它。"
+ }
+ }
+ }
+ },
+ "Homebrew on this Mac belongs to another account, so only that account can update or change it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew v tomto Macu patří jinému účtu, takže ho může aktualizovat nebo měnit jen ten účet."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew auf diesem Mac gehört einem anderen Benutzeraccount, daher kann nur dieser Benutzeraccount Homebrew aktualisieren oder ändern."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "El Homebrew de este Mac pertenece a otra cuenta, así que solo esa cuenta puede actualizarlo o modificarlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sur ce Mac, Homebrew appartient à un autre compte : seul ce compte peut donc le mettre à jour ou le modifier."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew su questo Mac appartiene a un altro account, quindi solo quell’account può aggiornarlo o modificarlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "このMacのHomebrewは別のアカウントのものであるため、アップデートや変更ができるのはそのアカウントだけです。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 Mac의 Homebrew는 다른 계정에 속해 있으므로 해당 계정만 Homebrew를 업데이트하거나 변경할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew op deze Mac hoort bij een andere account, dus alleen die account kan Homebrew bijwerken of wijzigen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew na tym Macu należy do innego konta, więc tylko tamto konto może go odświeżać lub zmieniać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Homebrew deste Mac pertence a outra conta, então só essa conta pode atualizá-lo ou alterá-lo."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew de pe acest Mac aparține altui cont, așa că doar acel cont îl poate actualiza sau modifica."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew на этом Mac принадлежит другой учетной записи, поэтому обновлять или изменять его может только она."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew på den här datorn tillhör ett annat konto, så bara det kontot kan uppdatera eller ändra det."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bu Mac’teki Homebrew başka bir hesaba ait, bu yüzden onu yalnızca o hesap güncelleyebilir veya değiştirebilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Homebrew на цьому Mac належить іншому обліковому запису, тож лише той обліковий запис може оновлювати чи змінювати його."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "这台Mac上的Homebrew属于其他账户,因此只有该账户才能更新或更改它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "這部Mac上的Homebrew屬於另一個帳號,因此只有該帳號可以更新或更改它。"
+ }
+ }
+ }
+ },
"Homebrew ran into a problem. What it said is on the app’s page in Peel, if that page is still open." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index 8bd39a83..7cf77d34 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -239,6 +239,12 @@ public struct HomebrewInstallation: Sendable, Hashable {
public let prefix: URL
/// Where Homebrew keeps its formulae, as it says: in its repository when it has one there, else under the prefix.
public let cellar: URL
+ /// Where Homebrew itself is, as it says: the prefix on a Mac with Apple silicon, `/usr/local/Homebrew` on Intel.
+ public let repository: URL
+ /// The account the repository belongs to, which installed Homebrew.
+ public private(set) var owner: String?
+ /// Whether this account may change Homebrew (`Homebrew.mayBeChanged`), judged when it was read.
+ public private(set) var mayBeChangedByThisAccount = true
public var caskroom: URL {
prefix.appending(path: "Caskroom", directoryHint: .isDirectory)
@@ -256,16 +262,26 @@ public struct HomebrewInstallation: Sendable, Hashable {
/// `brew bundle` is part of Homebrew since 4.4.25; before, it lived in a tap that asking for it would download.
public var writesABrewfile: Bool { isAtLeast(4, 4, 25) }
- public init(version: String, prefix: URL, cellar: URL? = nil) {
+ public init(version: String, prefix: URL, cellar: URL? = nil, repository: URL? = nil) {
self.version = version
self.prefix = prefix
self.cellar = cellar ?? prefix.appending(path: "Cellar", directoryHint: .isDirectory)
+ self.repository = repository ?? prefix
numbers = version
.prefix { $0.isNumber || $0 == "." }
.split(separator: ".")
.compactMap { Int($0) }
}
+ /// A copy that says whose Homebrew this is and whether this account may change it.
+ func judgedForThisAccount() -> HomebrewInstallation {
+ var judged = self
+ let path = repository.path(percentEncoded: false)
+ judged.owner = (try? FileManager.default.attributesOfItem(atPath: path))?[.ownerAccountName] as? String
+ judged.mayBeChangedByThisAccount = Homebrew.mayBeChanged(cellar: cellar, repository: repository)
+ return judged
+ }
+
private func isAtLeast(_ required: Int...) -> Bool {
for (index, number) in required.enumerated() {
let mine = index < numbers.count ? numbers[index] : 0
@@ -485,6 +501,14 @@ indirect enum CaskValue: Decodable, Sendable {
public enum Homebrew {
static let notInstalled = "Homebrew isn’t installed."
+ /// Whether this account may change the Homebrew whose Cellar and repository these are, as `brew update` judges it
+ /// (`cmd/update.sh`): the Cellar, when there is one, and the repository can be written. Homebrew belongs to the
+ /// account that installed it, so another account of the Mac can read it and not change it.
+ static func mayBeChanged(cellar: URL, repository: URL) -> Bool {
+ func writable(_ url: URL) -> Bool { access(url.path(percentEncoded: false), W_OK) == 0 }
+ return (cellar.isMissing || writable(cellar)) && writable(repository)
+ }
+
/// Whether `sudo` stopped for a password it had no terminal to ask in, in its own words, which it writes in English
/// in the environment Peel runs Homebrew in.
public static func askedForAPassword(in transcript: String) -> Bool {
@@ -751,11 +775,13 @@ public enum Homebrew {
@concurrent
public static func installation() async -> HomebrewInstallation? {
guard executableURL != nil, let version = try? await answer(["--version"]) else { return nil }
- return installation(
+ let found = installation(
versionAnswer: version,
prefixAnswer: try? await answer(["--prefix"]),
- cellarAnswer: try? await answer(["--cellar"])
+ cellarAnswer: try? await answer(["--cellar"]),
+ repositoryAnswer: try? await answer(["--repository"])
)
+ return found?.judgedForThisAccount()
}
/// The installation as Homebrew describes it. Its prefix and Cellar are asked, never worked out from where `brew`
@@ -764,7 +790,8 @@ public enum Homebrew {
static func installation(
versionAnswer: String,
prefixAnswer: String?,
- cellarAnswer: String?
+ cellarAnswer: String?,
+ repositoryAnswer: String? = nil
) -> HomebrewInstallation? {
// The first line is `Homebrew <version>`; anything under it names a tap.
guard let first = versionAnswer.split(whereSeparator: \.isNewline).first else { return nil }
@@ -777,7 +804,8 @@ public enum Homebrew {
return HomebrewInstallation(
version: version,
prefix: URL(filePath: PathPattern.comparablePath(of: prefix), directoryHint: .notDirectory),
- cellar: cellar
+ cellar: cellar,
+ repository: repositoryAnswer.flatMap(folder(answering:))
)
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
index 639c2142..9a5501e0 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
@@ -12,10 +12,32 @@ struct HomebrewTests {
#expect(installation?.prefix.path(percentEncoded: false) == "/usr/local")
#expect(installation?.cellar.path(percentEncoded: false) == "/usr/local/Homebrew/Cellar/")
#expect(installation?.caskroom.path(percentEncoded: false) == "/usr/local/Caskroom/")
+ #expect(installation?.repository.path(percentEncoded: false) == "/usr/local")
+ let withRepository = Homebrew.installation(
+ versionAnswer: "Homebrew 7.0.9\n", prefixAnswer: "/usr/local\n", cellarAnswer: "/usr/local/Cellar\n",
+ repositoryAnswer: "/usr/local/Homebrew\n"
+ )
+ #expect(withRepository?.repository.path(percentEncoded: false) == "/usr/local/Homebrew/")
#expect(Homebrew.installation(versionAnswer: "Homebrew 7.0.9\n", prefixAnswer: nil, cellarAnswer: "/c\n") == nil)
#expect(Homebrew.installation(versionAnswer: "Homebrew 7.0.9\n", prefixAnswer: "/p\n", cellarAnswer: "c\n") == nil)
}
+ @Test(.permissionsHold) func knowsWhetherThisAccountMayChangeHomebrew() throws {
+ let directory = try TemporaryDirectory()
+ let repository = try directory.directory("homebrew")
+ let cellar = repository.appending(path: "Cellar", directoryHint: .isDirectory)
+
+ #expect(Homebrew.mayBeChanged(cellar: cellar, repository: repository), "a Cellar not made yet stops nothing")
+ try directory.directory("homebrew/Cellar")
+ #expect(Homebrew.mayBeChanged(cellar: cellar, repository: repository))
+ try directory.setPermissions(0o555, of: cellar)
+ #expect(!Homebrew.mayBeChanged(cellar: cellar, repository: repository))
+ try directory.setPermissions(0o755, of: cellar)
+ try directory.setPermissions(0o555, of: repository)
+ defer { try? directory.setPermissions(0o755, of: repository) }
+ #expect(!Homebrew.mayBeChanged(cellar: cellar, repository: repository))
+ }
+
@Test func aDisabledPackageWaitsForNoUpgrade() {
func package(_ stage: HomebrewRetirement.Stage?) -> HomebrewPackage {
HomebrewPackage(
diff --git a/Peel/Model/HomebrewLibrary.swift b/Peel/Model/HomebrewLibrary.swift
index 9ad30433..79e0d532 100644
--- a/Peel/Model/HomebrewLibrary.swift
+++ b/Peel/Model/HomebrewLibrary.swift
@@ -98,6 +98,19 @@ final class HomebrewLibrary {
var knowsItsOwnApps: Bool { !isInstalled || hasAnswered }
+ /// Whether this account may change Homebrew, true until Homebrew has been read. On another account of the Mac its
+ /// lists can be read, and what changes it is left to the account it belongs to.
+ var mayChange: Bool { installation?.mayBeChangedByThisAccount ?? true }
+
+ /// Why this account can't change Homebrew, or nil when it can.
+ var belongsToAnotherAccount: LocalizedStringResource? {
+ guard !mayChange else { return nil }
+ if let owner = installation?.owner {
+ return "Homebrew on this Mac belongs to \(owner), so only that account can update or change it."
+ }
+ return "Homebrew on this Mac belongs to another account, so only that account can update or change it."
+ }
+
/// Incremented only when the known casks or receipts change, or Homebrew leaves the Mac. An app's page scans
/// again when it does, so a page opened before the evidence arrived picks it up, and a page the user is working
/// on isn't scanned again for nothing.
@@ -288,7 +301,7 @@ final class HomebrewLibrary {
/// Homebrew page opens no sheet about it later.
@discardableResult
func run(_ command: Command, showsResult: Bool = true) async -> CommandResult? {
- guard runningCommand == nil, !isForgetting else { return nil }
+ guard runningCommand == nil, !isForgetting, command.onlyLooks || mayChange else { return nil }
runningCommand = command
defer {
(runningCommand, runningTask, progress, isStopping) = (nil, nil, nil, false)
@@ -314,7 +327,7 @@ final class HomebrewLibrary {
/// Moves the Homebrew receipt of each of `casks` whose apps are gone to the Trash, records it with `record`, and
/// reads the packages again, so Homebrew no longer lists them. Nil while Homebrew is busy.
func forget(_ casks: [HomebrewPackage], recording record: (TrashResult) async -> Void) async -> TrashResult? {
- guard runningCommand == nil, !isForgetting else { return nil }
+ guard runningCommand == nil, !isForgetting, mayChange else { return nil }
forgetting = Set(casks.map(\.id))
defer { forgetting = [] }
let result = await QuitGuard.shared.run {
diff --git a/Peel/Views/Homebrew/HomebrewDetailView.swift b/Peel/Views/Homebrew/HomebrewDetailView.swift
index dd28b44c..b1653269 100644
--- a/Peel/Views/Homebrew/HomebrewDetailView.swift
+++ b/Peel/Views/Homebrew/HomebrewDetailView.swift
@@ -118,57 +118,64 @@ struct HomebrewDetailView: View {
}
Section {
- HStack {
- if package.isMissingWhatItInstalled {
- Button("Forget Cask") { casksToForget = [package] }
- .buttonStyle(.borderedProminent)
- .disabled(!history.mayMove)
- .help(Text(verbatim: history.holdingReason?.explanation ?? ""))
- } else if package.waitsForAnUpgrade {
- if package.upgradeNeedsAnAdministrator || homebrew.overrides.contains(.cleansUp) {
- let kind = package.kind == .cask ? "--cask" : "--formula"
- CopyButton(text: "brew upgrade \(kind) \(package.fullName)", title: "Copy Upgrade Command")
+ if let anotherAccount = homebrew.belongsToAnotherAccount {
+ Text(anotherAccount)
+ .font(.callout)
+ .foregroundStyle(.secondary)
+ } else {
+ HStack {
+ if package.isMissingWhatItInstalled {
+ Button("Forget Cask") { casksToForget = [package] }
+ .buttonStyle(.borderedProminent)
+ .disabled(!history.mayMove)
+ .help(Text(verbatim: history.holdingReason?.explanation ?? ""))
+ } else if package.waitsForAnUpgrade {
+ if package.upgradeNeedsAnAdministrator || homebrew.overrides.contains(.cleansUp) {
+ let kind = package.kind == .cask ? "--cask" : "--formula"
+ CopyButton(text: "brew upgrade \(kind) \(package.fullName)", title: "Copy Upgrade Command")
+ } else {
+ Button("Upgrade", systemImage: "arrow.down.circle") {
+ isConfirmingUpgrade = true
+ }
+ .buttonStyle(.borderedProminent)
+ // A cask's apps, which have to quit first, are known only once they are matched.
+ .disabled(package.isPinned || package.kind == .cask && !library.knowsHomebrewsApps)
+ }
+ }
+ if isRunning {
+ ProgressView()
+ .controlSize(.small)
+ Text("Running Homebrew…")
+ .foregroundStyle(.secondary)
+ } else if let uninstallRefusal {
+ Label { Text(uninstallRefusal) } icon: { Image(systemName: "hand.raised.fill") }
+ .foregroundStyle(.secondary)
+ }
+ Spacer()
+ if isUninstalledInTerminal {
+ CopyButton(text: "brew uninstall --cask \(package.fullName)", title: "Copy Uninstall Command")
} else {
- Button("Upgrade", systemImage: "arrow.down.circle") {
- isConfirmingUpgrade = true
+ Button("Uninstall", systemImage: "trash", role: .destructive) {
+ isConfirmingUninstall = true
}
- .buttonStyle(.borderedProminent)
- // A cask's apps, which have to quit first, are known only once they are matched.
- .disabled(package.isPinned || package.kind == .cask && !library.knowsHomebrewsApps)
+ .disabled(uninstallRefusal != nil)
}
}
- if isRunning {
- ProgressView()
- .controlSize(.small)
- Text("Running Homebrew…")
- .foregroundStyle(.secondary)
- } else if let uninstallRefusal {
- Label { Text(uninstallRefusal) } icon: { Image(systemName: "hand.raised.fill") }
+ .disabled(
+ homebrew.runningCommand != nil || homebrew.isForgetting || quittingToUpgrade.isWaiting
+ || quittingToUninstall.isWaiting
+ )
+ if package.waitsForAnUpgrade, homebrew.overrides.contains(.cleansUp) {
+ Text(HomebrewLibrary.cleansUp)
+ .font(.callout)
.foregroundStyle(.secondary)
}
- Spacer()
- if isUninstalledInTerminal {
- CopyButton(text: "brew uninstall --cask \(package.fullName)", title: "Copy Uninstall Command")
- } else {
- Button("Uninstall", systemImage: "trash", role: .destructive) {
- isConfirmingUninstall = true
- }
- .disabled(uninstallRefusal != nil)
+ if (package.waitsForAnUpgrade && package.upgradeNeedsAnAdministrator) || isUninstalledInTerminal {
+ Text(needsTerminal)
+ .font(.callout)
+ .foregroundStyle(.secondary)
}
- }
- .disabled(
- homebrew.runningCommand != nil || homebrew.isForgetting || quittingToUpgrade.isWaiting
- || quittingToUninstall.isWaiting
- )
- if package.waitsForAnUpgrade, homebrew.overrides.contains(.cleansUp) {
- Text(HomebrewLibrary.cleansUp)
- .font(.callout)
- .foregroundStyle(.secondary)
- }
- if (package.waitsForAnUpgrade && package.upgradeNeedsAnAdministrator) || isUninstalledInTerminal {
- Text(needsTerminal)
- .font(.callout)
- .foregroundStyle(.secondary)
+
}
}
diff --git a/Peel/Views/Homebrew/HomebrewList.swift b/Peel/Views/Homebrew/HomebrewList.swift
index 149cd1de..03891e72 100644
--- a/Peel/Views/Homebrew/HomebrewList.swift
+++ b/Peel/Views/Homebrew/HomebrewList.swift
@@ -24,6 +24,11 @@ struct HomebrewList: View {
List(selection: $homebrew.selection) {
// While searching, the page lists only the matching packages and hides every other section.
if searchText.isEmpty, homebrew.isInstalled, !homebrew.needsDefinitions {
+ if let anotherAccount = homebrew.belongsToAnotherAccount {
+ Notice(title: Text("Homebrew Belongs to Another Account"), detail: Text(anotherAccount), kind: .note) {}
+ .padding(.vertical, 6)
+ .listRowSeparator(.hidden)
+ }
installation
overridden
maintenance
@@ -50,7 +55,8 @@ struct HomebrewList: View {
homebrew.isScanning,
found: homebrew.summary,
couldNotLook: !homebrew.isInstalled ? "Homebrew Isn’t Installed"
- : homebrew.needsDefinitions ? "Homebrew Has to Update First" : nil,
+ : !homebrew.needsDefinitions ? nil
+ : homebrew.mayChange ? "Homebrew Has to Update First" : "Homebrew Belongs to Another Account",
wasStopped: homebrew.scanRun.wasStopped
)
.toolbar {
@@ -441,7 +447,7 @@ struct HomebrewList: View {
}
.buttonStyle(.borderless)
.disabled(
- homebrew.upgradable.isEmpty || isBusy || quittingToUpgrade.isWaiting
+ homebrew.upgradable.isEmpty || isBusy || quittingToUpgrade.isWaiting || !homebrew.mayChange
|| homebrew.upgradable.contains { $0.kind == .cask } && !library.knowsHomebrewsApps
)
}
@@ -486,7 +492,7 @@ struct HomebrewList: View {
.minimumTarget()
}
.buttonStyle(.borderless)
- .disabled(isBusy || !history.mayMove)
+ .disabled(isBusy || !history.mayMove || !homebrew.mayChange)
.help(Text(verbatim: history.holdingReason?.explanation ?? ""))
}
}
@@ -574,7 +580,7 @@ struct HomebrewList: View {
trailing()
.buttonStyle(.bordered)
.controlSize(.small)
- .disabled(isBusy)
+ .disabled(isBusy || !command.onlyLooks && !homebrew.mayChange)
}
.padding(.vertical, 1)
}
@@ -635,6 +641,13 @@ struct HomebrewList: View {
}
Button("Homebrew Is in Another Folder") { SettingsPane.general.open(with: openSettings) }
}
+ } else if homebrew.needsDefinitions, homebrew.packages?.isEmpty != false, homebrew.runningCommand == nil,
+ let anotherAccount = homebrew.belongsToAnotherAccount {
+ ContentUnavailableView(
+ "Homebrew Belongs to Another Account",
+ systemImage: "person.crop.circle.badge.exclamationmark",
+ description: Text(anotherAccount)
+ )
} else if homebrew.needsDefinitions, homebrew.packages?.isEmpty != false, homebrew.runningCommand == nil {
ContentUnavailableView {
Label("Homebrew Has to Update First", systemImage: "arrow.down.circle")