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.

Believe a cask that quits the app's own helper

Țugui Dragoșee979cd2df0a
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/CaskEvidence.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/CaskEvidence.swift
index cc62cf08..c7483c0c 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/CaskEvidence.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/CaskEvidence.swift
@@ -112,7 +112,11 @@ public struct CaskEvidence: Sendable, Hashable {
let bundleName = app.url.lastPathComponent
if cask.appNames.contains(where: { $0.caseInsensitiveCompare(bundleName) == .orderedSame }) {
let maker = identifier.flatMap(Identifier.vendor(of:))
- if quits.isEmpty || quits.contains(where: { maker != nil && Identifier.vendor(of: $0) == maker }) {
+ let isTheAppsOrItsMakers = { (quit: String) in
+ identifier.map { quit.hasPrefix($0 + ".") } == true
+ || maker != nil && Identifier.vendor(of: quit) == maker
+ }
+ if quits.isEmpty || quits.contains(where: isTheAppsOrItsMakers) {
return true
}
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/KnownCasksTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/KnownCasksTests.swift
index 76721a27..0b594097 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/KnownCasksTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/KnownCasksTests.swift
@@ -106,6 +106,19 @@ struct KnownCasksTests {
#expect(CaskEvidence.proves(silent, isThe: domzilla))
}
+ @Test func aCaskThatQuitsTheAppsOwnHelperProvesAnAppWhoseIdentifierNamesNoMaker() {
+ let atlas = app("Atlas", "com.electron.atlas")
+ let ownHelper = HomebrewPackage(
+ name: "atlas", kind: .cask, appNames: ["Atlas.app"], quitIdentifiers: ["com.electron.atlas.helper"]
+ )
+ let anotherApp = HomebrewPackage(
+ name: "other-atlas", kind: .cask, appNames: ["Atlas.app"], quitIdentifiers: ["com.electron.other"]
+ )
+
+ #expect(CaskEvidence.proves(ownHelper, isThe: atlas))
+ #expect(!CaskEvidence.proves(anotherApp, isThe: atlas))
+ }
+
/// Two makers can give their apps one name, and Homebrew keeps the plain token for the one that came first:
/// here the `scribe` cask is one maker's editor, which ships `Scribe 2.app`, while another maker's app is
/// `Scribe.app`. The token guessed from the name points to the wrong cask, and only the proof keeps Peel from