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 why nothing in an orphan group can move on macOS 26 too

Țugui Dragoșd076b93b1067
diff --git a/Peel/Views/Orphans/OrphanDetailView.swift b/Peel/Views/Orphans/OrphanDetailView.swift
index 3909a7fa..53e2cae6 100644
--- a/Peel/Views/Orphans/OrphanDetailView.swift
+++ b/Peel/Views/Orphans/OrphanDetailView.swift
@@ -78,7 +78,7 @@ struct OrphanDetailView: View {
return lines.isEmpty ? nil : lines.joined(separator: "\n\n")
}
- private var whyNothingMoves: String? {
+ static func whyNothingMoves(in group: OrphanGroup) -> String? {
guard group.isLeftAlone else { return nil }
guard let reason = group.sharedReason else {
return String(localized: "Nothing here can be moved. Each file’s note says why.")
@@ -117,7 +117,7 @@ struct OrphanDetailView: View {
.font(.callout)
.foregroundStyle(.secondary)
}
- if #available(macOS 27, *), let why = whyNothingMoves {
+ if let why = Self.whyNothingMoves(in: group) {
Text(verbatim: why)
.font(.callout)
.foregroundStyle(.secondary)
diff --git a/PeelTests/OrphanNothingMovesTests.swift b/PeelTests/OrphanNothingMovesTests.swift
new file mode 100644
index 00000000..2ad0c8a6
--- /dev/null
+++ b/PeelTests/OrphanNothingMovesTests.swift
@@ -0,0 +1,32 @@
+import Foundation
+@testable import Peel
+@testable import PeelCore
+import Testing
+
+struct OrphanNothingMovesTests {
+ private func item(_ name: String, _ heldBack: HoldBack?) -> OrphanItem {
+ var item = OrphanItem(
+ url: URL(filePath: "/Users/x/Library/Containers/\(name)"), kind: .containers, size: 10,
+ modificationDate: nil, requiresPrivileges: false
+ )
+ item.heldBack = heldBack
+ return item
+ }
+
+ @Test func aGroupWhereNothingMovesSaysWhyAtItsHead() {
+ let documents = OrphanGroup(
+ identifier: "org.example.gone",
+ items: [item("org.example.gone", .holdsDocuments), item("org.example.gone.share", .holdsDocuments)]
+ )
+ let mixed = OrphanGroup(
+ identifier: "org.example.gone",
+ items: [item("org.example.gone", .holdsDocuments), item("org.example.gone.share", .holdsALibrary)]
+ )
+ let oneMoves = OrphanGroup(identifier: "org.example.gone", items: [item("org.example.gone", nil)])
+
+ let documentsReason = String(localized: HoldBack.holdsDocuments.explanation)
+ #expect(OrphanDetailView.whyNothingMoves(in: documents) == documentsReason)
+ #expect(OrphanDetailView.whyNothingMoves(in: mixed) == String(localized: "Nothing here can be moved. Each file’s note says why."))
+ #expect(OrphanDetailView.whyNothingMoves(in: oneMoves) == nil)
+ }
+}