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.

Leave a tool's own Time Machine mark to it in Build Artifacts

Țugui Dragoșb38c5dbb5675
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index b717f265..4a2e4e98 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -178761,6 +178761,112 @@
}
}
},
+ "Time Machine already leaves out %@, which something other than Peel marked." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine už vynechává %@, protože značku přidalo něco jiného než Peel."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine schließt %@ bereits aus. Diese Markierung stammt nicht von Peel."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine ya deja fuera %@, por una marca que no ha puesto Peel."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine exclut déjà %@, en raison d’une marque posée par autre chose que Peel."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine lascia già fuori %@, con un contrassegno messo da qualcosa di diverso da Peel."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@は、Peel以外の何かが印を付けたため、すでにTime Machineのバックアップ対象から外されています。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine이 이미 %@을(를) 제외하고 있습니다. 해당 폴더에는 Peel이 아닌 다른 무언가가 표시를 붙였습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine slaat %@ al over: iets anders dan Peel heeft die gemarkeerd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine już pomija to, co oznaczyło coś innego niż Peel: %@."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Time Machine já deixa %@ de fora, por uma marca que não foi feita pelo Peel."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine lasă deja în afară %@: marcajul nu a fost pus de Peel, ci de altceva."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine уже исключает %@ по отметке, которую поставил не Peel."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine utesluter redan %@, som något annat än Peel har märkt."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine, Peel dışında bir şeyin işaretlediklerini zaten dışarıda bırakıyor: %@."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Time Machine уже не долучає %@: позначку поставила не Peel, а щось інше."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "时间机器已经跳过%@,这些文件夹由Peel以外的程序标记。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "「時光機」已經略過%@,這是由Peel以外的程式所標記的。"
+ }
+ }
+ }
+ },
"Time Machine already leaves out some of these, through a folder above them or a rule of its own, so that part isn’t Peel’s to change." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 00deb557..7b33d518 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -68,6 +68,9 @@ public enum ProjectArtifacts {
public let markable: [URL]
/// The folders carrying Peel's own mark, which turning the switch off takes away.
public let marked: [URL]
+ /// The folders whose own mark is another's: Peel never marks a folder with a generic name, so a mark on one is
+ /// its tool's, as Cargo marks `target`, or the person's. The switch neither shows it nor takes it away.
+ public let markedByOthers: [URL]
private let shown: [URL]
private let excluded: Set<URL>
@@ -75,8 +78,12 @@ public enum ProjectArtifacts {
public init(_ artifacts: [ProjectArtifact], excluded: Set<URL>, excludedFromAbove: Set<URL>) {
let considered = artifacts.filter { !$0.hasGenericName && !$0.isEnvironment && $0.heldBack == nil }
.map(\.url)
+ let markedItself = { (artifact: ProjectArtifact) in
+ excluded.contains(artifact.url) && !excludedFromAbove.contains(artifact.url)
+ }
markable = considered.filter { !excludedFromAbove.contains($0) }
- marked = artifacts.map(\.url).filter { excluded.contains($0) && !excludedFromAbove.contains($0) }
+ marked = artifacts.filter { markedItself($0) && !$0.hasGenericName }.map(\.url)
+ markedByOthers = artifacts.filter { markedItself($0) && $0.hasGenericName }.map(\.url)
shown = considered + marked.filter { !considered.contains($0) }
self.excluded = excluded
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index f686cfdb..1c7abd7c 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -133,6 +133,26 @@ struct ProjectArtifactsTests {
#expect(!marks(excluded: [modules.url], excludedFromAbove: [modules.url], of: [modules]).canChange)
}
+ @Test func theBackupSwitchLeavesAToolsOwnMarkAlone() {
+ func artifact(_ name: String, isGeneric: Bool = false) -> ProjectArtifact {
+ ProjectArtifact(
+ url: URL(filePath: "/Users/x/Code/App/\(name)"), project: URL(filePath: "/Users/x/Code/App"), name: name,
+ tool: "tool", size: 10, lastActivity: nil, hasGenericName: isGeneric, isEnvironment: false
+ )
+ }
+ let target = artifact("target", isGeneric: true)
+ let modules = artifact("node_modules")
+
+ let cargo = ProjectArtifacts.BackupMarks([target], excluded: [target.url], excludedFromAbove: [])
+ #expect(!cargo.isOn && !cargo.canChange)
+ #expect(cargo.markedByOthers == [target.url])
+ let mixed = ProjectArtifacts.BackupMarks(
+ [modules, target], excluded: [modules.url, target.url], excludedFromAbove: []
+ )
+ #expect(mixed.isOn)
+ #expect(mixed.folders(turning: false) == [modules.url])
+ }
+
@Test func saysWhenAProjectLastChangedOnlyWhenItKnows() {
func artifact(_ name: String, changed: Date?, certain: Bool) -> ProjectArtifact {
let project = URL(filePath: "/Users/x/Code/App")
diff --git a/Peel/Model/ProjectLibrary.swift b/Peel/Model/ProjectLibrary.swift
index 9808a14f..85a5c056 100644
--- a/Peel/Model/ProjectLibrary.swift
+++ b/Peel/Model/ProjectLibrary.swift
@@ -140,6 +140,10 @@ final class ProjectLibrary {
backupMarks(group).canChange
}
+ func markedByOthers(in group: ProjectGroup) -> [URL] {
+ backupMarks(group).markedByOthers
+ }
+
/// Excludes the group's artifacts from Time Machine backups, or includes them again, so a backup holds the
/// project and not what a build can make again.
func setExcludedFromBackups(_ isExcluded: Bool, in group: ProjectGroup) {
diff --git a/Peel/Views/Projects/ProjectDetailView.swift b/Peel/Views/Projects/ProjectDetailView.swift
index 77f772cb..01b11970 100644
--- a/Peel/Views/Projects/ProjectDetailView.swift
+++ b/Peel/Views/Projects/ProjectDetailView.swift
@@ -80,14 +80,25 @@ struct ProjectDetailView: View {
set: { projects.setExcludedFromBackups($0, in: group) }
)
let explanation = String(localized: "Backups keep the project and skip the folders listed here, installed packages included. Environments such as .venv and .terraform stay in backups, as do folders whose name could mean anything and folders Peel doesn’t select because of what is inside. The mark sits on the folder itself: it moves with the folder, and a folder that a build deletes and makes again comes back without it.")
+ let others = projects.markedByOthers(in: group).map(\.lastPathComponent)
+ let othersNote = others.isEmpty ? nil : String(localized: "Time Machine already leaves out \(others.formatted(.list(type: .and))), which something other than Peel marked.")
return HStack(alignment: .checkboxTitleLine, spacing: 5) {
- NativeCheckbox(isOn: isOn, label: String(localized: "Leave these out of Time Machine"), hint: explanation)
+ NativeCheckbox(
+ isOn: isOn,
+ label: String(localized: "Leave these out of Time Machine"),
+ hint: [explanation, othersNote].compactMap(\.self).joined(separator: " ")
+ )
VStack(alignment: .leading, spacing: 2) {
Text("Leave these out of Time Machine")
.checkboxTitleLine()
Text(verbatim: explanation)
.font(.caption)
.foregroundStyle(.secondary)
+ if let othersNote {
+ Text(verbatim: othersNote)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
}
.checkboxTitle()
.contentShape(.rect)