Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Turn to Homebrew under every preference once the app's own source can't
Țugui Dragoșfae2a687b3be
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 7d2f8b8f..e39bd457 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -19156,108 +19156,108 @@}}},- "Automatic asks Homebrew first about an app Homebrew installed, then the app’s own feed or the App Store. When the source you prefer can’t answer for an app, its own feed does." : {+ "Automatic asks Homebrew first about an app Homebrew installed, then the app’s own feed or the App Store. Any other choice puts the source you prefer first, then the app’s own feed, then Homebrew for an app it installed." : {"localizations" : {"cs" : {"stringUnit" : {"state" : "translated",- "value" : "Volba Automaticky se u aplikace nainstalované přes Homebrew ptá nejprve Homebrew, potom vlastního kanálu aplikace nebo App Storu. Když zdroj, kterému dáváte přednost, za aplikaci odpovědět nemůže, odpoví její vlastní kanál."+ "value" : "Volba Automaticky se u aplikace nainstalované přes Homebrew ptá nejprve Homebrew, potom vlastního kanálu aplikace nebo App Storu. Jakákoli jiná volba řadí na první místo zdroj, kterému dáváte přednost, potom vlastní kanál aplikace a nakonec Homebrew u aplikace, kterou nainstaloval."}},"de" : {"stringUnit" : {"state" : "translated",- "value" : "„Automatisch“ fragt bei einer von Homebrew installierten App zuerst Homebrew, dann den eigenen Feed der App oder den App Store. Wenn die bevorzugte Quelle für eine App keine Antwort geben kann, antwortet stattdessen der eigene Feed der App."+ "value" : "„Automatisch“ fragt bei einer von Homebrew installierten App zuerst Homebrew, dann den eigenen Feed der App oder den App Store. Bei jeder anderen Option kommt zuerst die bevorzugte Quelle, dann der eigene Feed der App und bei einer von Homebrew installierten App zuletzt Homebrew."}},"es" : {"stringUnit" : {"state" : "translated",- "value" : "La opción Automático pregunta primero a Homebrew por una app instalada con Homebrew, y después al canal de la propia app o a App Store. Cuando el origen que prefieres no puede responder por una app, responde su propio canal."+ "value" : "La opción Automático pregunta primero a Homebrew por una app instalada con Homebrew, y después al canal de la propia app o a App Store. Cualquier otra opción pone primero el origen que prefieres, después el canal de la propia app y luego Homebrew en el caso de una app instalada con él."}},"fr" : {"stringUnit" : {"state" : "translated",- "value" : "« Automatique » interroge d’abord Homebrew pour une app installée par Homebrew, puis le flux propre à l’app ou l’App Store. Lorsque la source que vous préférez ne peut pas répondre pour une app, c’est le flux propre à l’app qui répond."+ "value" : "« Automatique » interroge d’abord Homebrew pour une app installée par Homebrew, puis le flux propre à l’app ou l’App Store. Tout autre choix place en premier la source que vous préférez, puis le flux propre à l’app, puis Homebrew pour une app qu’il a installée."}},"it" : {"stringUnit" : {"state" : "translated",- "value" : "“Automatico” chiede prima a Homebrew di un’app installata da Homebrew, poi al feed dell’app o ad App Store. Quando la fonte che preferisci non può rispondere per un’app, risponde il feed dell’app stessa."+ "value" : "“Automatico” chiede prima a Homebrew di un’app installata da Homebrew, poi al feed dell’app o ad App Store. Qualsiasi altra scelta mette al primo posto la fonte che preferisci, poi il feed dell’app, poi Homebrew per un’app installata da Homebrew."}},"ja" : {"stringUnit" : {"state" : "translated",- "value" : "“自動”では、Homebrewでインストールしたアプリについては最初にHomebrewに問い合わせ、次にアプリ独自のフィードまたはApp Storeに問い合わせます。優先するアップデート元がアプリについて応答できない場合は、アプリ独自のフィードが応答します。"+ "value" : "“自動”では、Homebrewでインストールしたアプリについては最初にHomebrewに問い合わせ、次にアプリ独自のフィードまたはApp Storeに問い合わせます。それ以外の選択肢では、優先するアップデート元、アプリ独自のフィードの順に問い合わせ、Homebrewでインストールしたアプリについては最後にHomebrewに問い合わせます。"}},"ko" : {"stringUnit" : {"state" : "translated",- "value" : "‘자동’은 Homebrew가 설치한 앱에 대해 먼저 Homebrew에 묻고, 그다음 앱 자체 피드나 App Store에 묻습니다. 선호하는 출처가 어떤 앱에 대해 응답할 수 없으면 그 앱의 자체 피드가 응답합니다."+ "value" : "‘자동’은 Homebrew가 설치한 앱에 대해 먼저 Homebrew에 묻고, 그다음 앱 자체 피드나 App Store에 묻습니다. 다른 항목을 선택하면 선호하는 출처에 먼저 묻고, 그다음 앱 자체 피드에, 그다음 Homebrew가 설치한 앱에 대해서는 Homebrew에 묻습니다."}},"nl" : {"stringUnit" : {"state" : "translated",- "value" : "'Automatisch' vraagt bij een app die Homebrew heeft geïnstalleerd eerst Homebrew, en daarna de eigen feed van de app of de App Store. Als de bron van je voorkeur geen antwoord kan geven voor een app, doet de eigen feed van die app dat."+ "value" : "'Automatisch' vraagt bij een app die Homebrew heeft geïnstalleerd eerst Homebrew, en daarna de eigen feed van de app of de App Store. Bij elke andere keuze komt eerst de bron van je voorkeur, daarna de eigen feed van de app en dan Homebrew bij een app die ermee is geïnstalleerd."}},"pl" : {"stringUnit" : {"state" : "translated",- "value" : "Opcja Automatycznie najpierw pyta Homebrew o aplikację zainstalowaną przez Homebrew, a potem kanał aplikacji lub App Store. Gdy preferowane źródło nie może odpowiedzieć w sprawie aplikacji, odpowiada jej własny kanał."+ "value" : "Opcja Automatycznie najpierw pyta Homebrew o aplikację zainstalowaną przez Homebrew, a potem kanał aplikacji lub App Store. Każda inna opcja stawia na pierwszym miejscu preferowane źródło, potem kanał aplikacji, a potem Homebrew w przypadku aplikacji, którą zainstalował."}},"pt" : {"stringUnit" : {"state" : "translated",- "value" : "A opção Automático pergunta primeiro ao Homebrew sobre um app que o Homebrew instalou, depois ao feed do próprio app ou à App Store. Quando a fonte que você prefere não consegue responder por um app, o feed do próprio app responde."+ "value" : "A opção Automático pergunta primeiro ao Homebrew sobre um app que o Homebrew instalou, depois ao feed do próprio app ou à App Store. Qualquer outra opção coloca primeiro a fonte que você prefere, depois o feed do próprio app e depois o Homebrew no caso de um app que ele instalou."}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Opțiunea „Automat” întreabă mai întâi Homebrew despre o aplicație instalată de Homebrew, apoi fluxul propriu al aplicației sau App Store. Când sursa preferată nu poate răspunde pentru o aplicație, răspunde fluxul propriu al acesteia."+ "value" : "Opțiunea „Automat” întreabă mai întâi Homebrew despre o aplicație instalată de Homebrew, apoi fluxul propriu al aplicației sau App Store. Orice altă opțiune pune sursa preferată pe primul loc, apoi fluxul propriu al aplicației, apoi Homebrew pentru o aplicație instalată de acesta."}},"ru" : {"stringUnit" : {"state" : "translated",- "value" : "В режиме «Автоматически» Peel сначала спрашивает Homebrew о приложениях, установленных через Homebrew, а затем ленту самого приложения или App Store. Если предпочитаемый источник не может ответить о приложении, отвечает его собственная лента."+ "value" : "В режиме «Автоматически» Peel сначала спрашивает Homebrew о приложениях, установленных через Homebrew, а затем ленту самого приложения или App Store. При выборе любого другого варианта Peel сначала спрашивает предпочитаемый источник, затем ленту самого приложения, а затем Homebrew о приложениях, установленных через него."}},"sv" : {"stringUnit" : {"state" : "translated",- "value" : "Med Automatiskt tillfrågas först Homebrew om en app som Homebrew har installerat, och därefter appens eget flöde eller App Store. När källan du föredrar inte kan svara för en app svarar appens eget flöde."+ "value" : "Med Automatiskt tillfrågas först Homebrew om en app som Homebrew har installerat, och därefter appens eget flöde eller App Store. Med alla andra val kommer källan du föredrar först, därefter appens eget flöde och sist Homebrew för en app som Homebrew har installerat."}},"tr" : {"stringUnit" : {"state" : "translated",- "value" : "Otomatik, Homebrew’un yüklediği bir uygulama için önce Homebrew’a, sonra uygulamanın kendi akışına veya App Store’a sorar. Tercih ettiğiniz kaynak bir uygulama için yanıt veremediğinde, yanıtı uygulamanın kendi akışı verir."+ "value" : "Otomatik, Homebrew’un yüklediği bir uygulama için önce Homebrew’a, sonra uygulamanın kendi akışına veya App Store’a sorar. Diğer seçenekler ise tercih ettiğiniz kaynağı ilk sıraya koyar; ardından uygulamanın kendi akışı, sonra da Homebrew’un yüklediği bir uygulama için Homebrew gelir."}},"uk" : {"stringUnit" : {"state" : "translated",- "value" : "«Автоматично» спершу запитує Homebrew про програму, яку інсталював Homebrew, а потім власну стрічку програми або App Store. Коли вибране вами джерело не може відповісти щодо програми, відповідає її власна стрічка."+ "value" : "«Автоматично» спершу запитує Homebrew про програму, яку інсталював Homebrew, а потім власну стрічку програми або App Store. Будь-який інший варіант ставить на перше місце вибране вами джерело, потім власну стрічку програми, а потім Homebrew для програми, яку він інсталював."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "选择“自动”时,对于由Homebrew安装的App,会先询问Homebrew,然后询问App自己的更新源或App Store。如果你首选的来源无法提供某个App的更新信息,则改为询问该App自己的更新源。"+ "value" : "选择“自动”时,对于由Homebrew安装的App,会先询问Homebrew,然后询问App自己的更新源或App Store。选择其他选项时,会先询问你首选的来源,然后询问App自己的更新源,对于由Homebrew安装的App,最后询问Homebrew。"}},"zh-Hant" : {"stringUnit" : {"state" : "translated",- "value" : "「自動」會先向Homebrew查詢由Homebrew安裝的App,再查詢App自己的Feed或App Store。當你偏好的來源無法回答某個App的更新時,就改由它自己的Feed回答。"+ "value" : "「自動」會先向Homebrew查詢由Homebrew安裝的App,再查詢App自己的Feed或App Store。其他選項則會先查詢你偏好的來源,再查詢App自己的Feed,最後才向Homebrew查詢由它安裝的App。"}}}diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swiftindex c47f976d..f0f1ed0f 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift@@ -75,54 +75,54 @@ public struct UpdateChecker: Sendable {if let status = Self.statusWithoutAsking(for: app, preference: preference, homebrew: homebrew) {return UpdateAnswer(status: status)}- switch preference {- case .homebrew, .developer:- return await feedAnswer(for: app, earlier: earlier)- case .appStore:- // Even with this preference, Apple is asked only about apps from the App Store. Any other app is- // checked through its own feed, or not at all.- return app.isFromAppStore- ? await appStoreAnswer(for: app, earlier: earlier) : await feedAnswer(for: app, earlier: earlier)- case .automatic:- // A feed can be down, and the App Store may not sell the app here: what Homebrew knows is used then.- let feed = await feedAnswer(for: app, earlier: earlier)- if let homebrew, feed.status == .unsupported || feed.status == .failed {- return UpdateAnswer(status: homebrew, developer: feed.developer)- }- return feed+ // Even with the App Store preferred, Apple is asked only about apps from the App Store. Any other app is+ // checked through its own feed, or not at all.+ let own = preference == .appStore && app.isFromAppStore+ ? await appStoreAnswer(for: app, earlier: earlier) : await feedAnswer(for: app, earlier: earlier)+ // A feed can be down, and the App Store may not sell the app here: what Homebrew knows is used then.+ if let homebrew, own.status == .unsupported || own.status == .failed {+ return UpdateAnswer(status: homebrew, developer: own.developer)}+ return own}/// The status `answer(for:preference:casks:earlier:)` gives `app` without asking any server, from Homebrew's/// casks and the app's own files alone, or nil when the app's own feed or the App Store has to be asked.+ /// `known` is the answer shown now: when it says the app's own source had no answer, what Homebrew knows now+ /// answers in its place, as a check would.public func statusWithoutAsking(- for app: InstalledApp, preference: UpdateSource, casks: [HomebrewPackage]+ for app: InstalledApp, preference: UpdateSource, casks: [HomebrewPackage], known: UpdateStatus? = nil) -> UpdateStatus? {- Self.statusWithoutAsking(for: app, preference: preference, homebrew: homebrewStatus(for: app, casks: casks))+ let homebrew = homebrewStatus(for: app, casks: casks)+ if let status = Self.statusWithoutAsking(for: app, preference: preference, homebrew: homebrew) {+ return status+ }+ return known == .unsupported || known == .failed ? homebrew : nil}private static func statusWithoutAsking(for app: InstalledApp, preference: UpdateSource, homebrew: UpdateStatus?) -> UpdateStatus? {- // An app whose bundle names no version, or no feed, has nothing to ask.- let hasNobodyToAsk = app.version == nil || app.updateFeed == nil+ let asksNobody = asksNobody(about: app, preference: preference)switch preference {case .homebrew:// A cask Homebrew knows but never installed says nothing about this app's version, and neither does one// Homebrew can't tell about, so the app's own feed answers then instead of a false "up to date".- return homebrew ?? (hasNobodyToAsk ? .unsupported : nil)- case .automatic:- if case .updateAvailable = homebrew { return homebrew }+ return homebrew ?? (asksNobody ? .unsupported : nil)+ case .automatic, .developer, .appStore:+ if preference == .automatic, case .updateAvailable = homebrew { return homebrew }// An app from a cask may have no feed of its own: what Homebrew knows is used rather than "Can't check// for updates".- return hasNobodyToAsk ? homebrew ?? .unsupported : nil- case .developer:- return hasNobodyToAsk ? .unsupported : nil- case .appStore:- return hasNobodyToAsk && !app.isFromAppStore ? .unsupported : nil+ return asksNobody ? homebrew ?? .unsupported : nil}}+ /// Whether a check of `app` has no server to ask: its bundle names no version or no feed, and it isn't an app+ /// from the App Store with the App Store preferred.+ private static func asksNobody(about app: InstalledApp, preference: UpdateSource) -> Bool {+ (app.version == nil || app.updateFeed == nil) && !(preference == .appStore && app.isFromAppStore)+ }+/// Homebrew's answer for `app`, found without a network request, or nil when Homebrew did not install this copy/// or can't tell (`homebrewStatus(of:at:)`). For a cask it did not install, Homebrew has a definition but no/// installed version to compare.@@ -148,7 +148,7 @@ public struct UpdateChecker: Sendable {public func caskNotCheckedRecently(for app: InstalledApp, preference: UpdateSource, casks: [HomebrewPackage]) -> HomebrewPackage? {- guard preference == .automatic || preference == .homebrew, app.version == nil || app.updateFeed == nil,+ guard Self.asksNobody(about: app, preference: preference),let cask = CaskEvidence.installedCask(for: app, in: casks)else { return nil }return Self.homebrewStatus(of: cask, at: clock()) == nil ? cask : nildiff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swiftindex b3423ad1..c4551dee 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdateCheckerTests.swift@@ -230,7 +230,7 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {#expect(recent.statusWithoutAsking(for: feedlessApp, preference: .automatic, casks: current) == .upToDate)#expect(later.statusWithoutAsking(for: feedlessApp, preference: .automatic, casks: current) == .unsupported)- #expect(later.statusWithoutAsking(for: feedlessApp, preference: .developer, casks: outdated) == .unsupported)+ #expect(later.statusWithoutAsking(for: feedlessApp, preference: .developer, casks: outdated) == update)#expect(later.statusWithoutAsking(for: fedApp, preference: .automatic, casks: outdated) == update)#expect(recent.statusWithoutAsking(for: fedApp, preference: .automatic, casks: current) == nil, "feed first")#expect(recent.statusWithoutAsking(for: fedApp, preference: .homebrew, casks: current) == .upToDate)@@ -253,12 +253,60 @@ private final class CannedProtocol: URLProtocol, @unchecked Sendable {later.caskNotCheckedRecently(for: feedlessApp, preference: .automatic, casks: outdated) == nil,"an update Homebrew knows of is an answer")- #expect(later.caskNotCheckedRecently(for: feedlessApp, preference: .developer, casks: current) == nil)- #expect(later.caskNotCheckedRecently(for: feedlessApp, preference: .appStore, casks: current) == nil)+ #expect(later.caskNotCheckedRecently(for: feedlessApp, preference: .developer, casks: current)?.name == "example")+ #expect(later.caskNotCheckedRecently(for: feedlessApp, preference: .appStore, casks: current)?.name == "example")+ #expect(later.caskNotCheckedRecently(for: soldApp, preference: .appStore, casks: current) == nil, "Apple asked")#expect(later.caskNotCheckedRecently(for: fedApp, preference: .automatic, casks: current) == nil, "its feed")#expect(later.caskNotCheckedRecently(for: feedlessApp, preference: .automatic, casks: []) == nil)}+ private var soldApp: InstalledApp {+ InstalledApp(+ url: feedlessApp.url, bundleIdentifier: feedlessApp.bundleIdentifier, name: feedlessApp.name,+ version: "1.0", isFromAppStore: true, updateFeed: .appStore(.mac)+ )+ }++ @Test func everyPreferenceTurnsToHomebrewOnceItsOwnSourceCanNotAnswer() async {+ let recent = checking(at: homebrewChecked + 60 * 60)+ let later = checking(at: homebrewChecked + 2 * Homebrew.autoUpdateInterval)+ let current = [cask(checked: homebrewChecked)]+ let outdated = [cask(latest: "2.0", checked: homebrewChecked)]+ let update = UpdateStatus.updateAvailable(version: "2.0", source: .homebrew, releaseNotes: nil)+ reply("nowhere.example.com", "")++ #expect(await recent.status(for: feedlessApp, preference: .developer, casks: current) == .upToDate)+ #expect(await recent.status(for: feedlessApp, preference: .appStore, casks: current) == .upToDate)+ #expect(await recent.status(for: feedlessApp, preference: .developer, casks: outdated) == update)+ #expect(await later.status(for: feedlessApp, preference: .developer, casks: current) == .unsupported)+ #expect(CannedProtocol.asked.withLock { $0 }.isEmpty)++ reply("feed.example.com", status: 500, "")+ #expect(await recent.status(for: fedApp, preference: .developer, casks: current) == .upToDate)++ reply("feed.example.com", appcast("<item><enclosure url=\"https://feed.example.com/a.zip\" sparkle:version=\"100\" sparkle:shortVersionString=\"1.0\" /></item>"))+ #expect(await recent.status(for: fedApp, preference: .developer, casks: outdated) == .upToDate, "its feed first")+ #expect(await recent.status(for: fedApp, preference: .automatic, casks: outdated) == update)+ }++ @Test func aSourceThatHadNoAnswerGivesWayToWhatHomebrewKnowsNow() {+ let recent = checking(at: homebrewChecked + 60 * 60)+ let later = checking(at: homebrewChecked + 2 * Homebrew.autoUpdateInterval)+ let current = [cask(checked: homebrewChecked)]+ let found = UpdateStatus.updateAvailable(version: "1.1", source: .developer, releaseNotes: nil)+ let decided = { (checker: UpdateChecker, preference: UpdateSource, known: UpdateStatus?) in+ checker.statusWithoutAsking(for: fedApp, preference: preference, casks: current, known: known)+ }++ #expect(decided(recent, .developer, .failed) == .upToDate)+ #expect(decided(recent, .appStore, .unsupported) == .upToDate)+ #expect(decided(recent, .automatic, .failed) == .upToDate)+ #expect(decided(recent, .developer, .upToDate) == nil)+ #expect(decided(recent, .developer, found) == nil)+ #expect(decided(recent, .developer, nil) == nil)+ #expect(decided(later, .developer, .failed) == nil)+ }+@Test func aMacAppReadsNoIPhoneRecord() async {let sold = InstalledApp(url: URL(filePath: "/Applications/Notes Pro.app"),diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swiftindex 5ff9935e..c01c9ff1 100644--- a/Peel/Model/AppLibrary.swift+++ b/Peel/Model/AppLibrary.swift@@ -587,7 +587,9 @@ final class AppLibrary {// Homebrew may have been read again while this answer was on its way: its casks decide where they can.let status = casks == self.casks? answer.status- : checker.statusWithoutAsking(for: app, preference: preference, casks: self.casks) ?? answer.status+ : checker.statusWithoutAsking(+ for: app, preference: preference, casks: self.casks, known: answer.status+ ) ?? answer.statuslet kept = status.following(updateStatuses[id])// Any write redraws the whole Applications list, so an answer that changes nothing is not written.if updateStatuses[id] != kept {@@ -798,24 +800,17 @@ final class AppLibrary {UpdateMemoryStore.save(memory, to: defaults)}- /// Shows for each app Homebrew installed what a check would answer now without asking any server, from Homebrew's- /// casks and the app's own files. Reading Homebrew costs no network request, so this doesn't wait for the update- /// schedule, and Applications agrees with the Homebrew page. A check never asks Homebrew while the app's own feed- /// or the App Store is preferred: then only an update Homebrew knows of fills in for an app whose own check has- /// nothing, a failure, or no feed to ask.+ /// Shows for each app Homebrew installed what a check would answer now without asking any server: what+ /// Homebrew's casks and the app's own files decide, and what Homebrew knows where the app's own source had no+ /// answer. Reading Homebrew costs no network request, so this doesn't wait for the update schedule, and+ /// Applications agrees with the Homebrew page.private func applyHomebrewStatuses() {let preference = updateSourcefor app in apps where homebrewApps[app.id] != nil && isAskedAboutUpdates(app) {let known = updateStatuses[app.id]- let decided: UpdateStatus?- switch preference {- case .automatic, .homebrew:- decided = updateChecker.statusWithoutAsking(for: app, preference: preference, casks: casks)- case .developer, .appStore:- let homebrew = updateChecker.homebrewStatus(for: app, casks: casks)- let hasNoAnswer = known == nil || known == .failed || known == .unsupported- decided = hasNoAnswer && homebrew?.version != nil ? homebrew : nil- }+ let decided = updateChecker.statusWithoutAsking(+ for: app, preference: preference, casks: casks, known: known+ )guard let decided, decided != known else { continue }updateStatuses[app.id] = decided}diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex 0d4cb7aa..4ded4200 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -243,7 +243,7 @@ private struct GeneralSettingsView: View {.accessibilityLabel(Text("Prefer updates from"))} label: {titled("Prefer updates from",- "Automatic asks Homebrew first about an app Homebrew installed, then the app’s own feed or the App Store. When the source you prefer can’t answer for an app, its own feed does.")+ "Automatic asks Homebrew first about an app Homebrew installed, then the app’s own feed or the App Store. Any other choice puts the source you prefer first, then the app’s own feed, then Homebrew for an app it installed.")}.disabled(!checksForAppUpdates).onChange(of: updateSource) { _, _ indiff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swiftindex 8734ede7..db0363fe 100644--- a/PeelTests/AppLibraryTests.swift+++ b/PeelTests/AppLibraryTests.swift@@ -311,4 +311,46 @@ private nonisolated final class TestClock: Sendable {await round.value#expect(library.shownUpdateStatus(of: app)?.version == "2.0", "the feed was asked with what Homebrew said before")}++ @Test func withTheAppsOwnFeedPreferredHomebrewAnswersForAnAppWithNoFeed() async throws {+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")+ let bundle = try caskApp("Tool", in: folder)+ defer { try? FileManager.default.removeItem(at: folder) }+ let made = try MadeUpDefaults()+ defer { made.forget() }+ made.defaults.set(UpdateSource.developer.rawValue, forKey: SettingsKey.updateSource)+ let clock = TestClock(homebrewChecked + 60 * 60)+ let library = library(with: made.defaults, notesIn: folder, clock: clock)++ #expect(await library.reveal([bundle]))+ let app = try #require(library.apps.first { $0.bundleIdentifier == "org.example.tool" })+ library.loadHomebrewCasks([cask("Tool", checked: homebrewChecked)], knowsItsOwnApps: true)+ #expect(library.shownUpdateStatus(of: app) == .upToDate)++ library.loadHomebrewCasks([cask("Tool", latest: "2.0", checked: homebrewChecked)], knowsItsOwnApps: true)+ #expect(library.shownUpdateStatus(of: app)?.version == "2.0")++ clock.set(homebrewChecked + 2 * Homebrew.autoUpdateInterval)+ library.loadHomebrewCasks([cask("Tool", checked: homebrewChecked)], knowsItsOwnApps: true)+ #expect(library.shownUpdateStatus(of: app) == .unsupported)+ }++ @Test func aFeedThatFailedGivesWayToWhatHomebrewKnowsOnceHomebrewIsRead() async throws {+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")+ let bundle = try caskApp("Fed", in: folder, feed: "https://feed.example.com/appcast.xml")+ defer { try? FileManager.default.removeItem(at: folder) }+ let made = try MadeUpDefaults()+ defer { made.forget() }+ made.defaults.set(UpdateSource.developer.rawValue, forKey: SettingsKey.updateSource)+ AppcastProtocol.body.withLock { $0 = Data() }+ let library = library(with: made.defaults, notesIn: folder, clock: TestClock(homebrewChecked + 60 * 60))++ #expect(await library.reveal([bundle]))+ let app = try #require(library.apps.first { $0.bundleIdentifier == "org.example.fed" })+ await library.checkForUpdates([app], force: true)+ #expect(library.shownUpdateStatus(of: app) == .failed)++ library.loadHomebrewCasks([cask("Fed", checked: homebrewChecked)], knowsItsOwnApps: true)+ #expect(library.shownUpdateStatus(of: app) == .upToDate)+ }}