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.

Time Machine keeps backing up project environments

Țugui Dragoș3186d0f027be
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 16814671..f1f21874 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -53,9 +53,10 @@ public enum ProjectArtifacts {
}
/// The artifacts to leave out of Time Machine: never one with a generic name, since the mark travels with the
- /// folder, even into a copy of it (`man tmutil`).
+ /// folder, even into a copy of it (`man tmutil`), and never an environment, which holds what no build makes
+ /// again (`.terraform` keeps the chosen workspace and the backend's settings).
public static func markableForBackups(_ artifacts: [ProjectArtifact], excludedFromAbove: Set<URL>) -> [URL] {
- artifacts.filter { !$0.hasGenericName && !excludedFromAbove.contains($0.url) }.map(\.url)
+ artifacts.filter { !$0.hasGenericName && !$0.isEnvironment && !excludedFromAbove.contains($0.url) }.map(\.url)
}
struct Definition: Sendable {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index f7f2e950..7c59da48 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -41,17 +41,19 @@ struct ProjectArtifactsTests {
/// Machine already leaves out through a folder above it, whose exclusion is not its own to change. A project
/// with nothing else gives the checkbox nothing to do.
@Test func marksForBackupsOnlyWhatABuildCertainlyMakesAgain() {
- func artifact(_ name: String, isGeneric: Bool) -> ProjectArtifact {
+ func artifact(_ name: String, isGeneric: Bool, isEnvironment: 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
+ tool: "tool", size: 10, lastActivity: nil, hasGenericName: isGeneric, isEnvironment: isEnvironment
)
}
let target = artifact("target", isGeneric: true)
let modules = artifact("node_modules", isGeneric: false)
let pods = artifact("Pods", isGeneric: false)
+ let terraform = artifact(".terraform", isGeneric: false, isEnvironment: true)
#expect(ProjectArtifacts.markableForBackups([target], excludedFromAbove: []).isEmpty)
+ #expect(ProjectArtifacts.markableForBackups([terraform], excludedFromAbove: []).isEmpty, "no build makes it")
#expect(ProjectArtifacts.markableForBackups([target, modules, pods], excludedFromAbove: [pods.url]) == [modules.url])
#expect(ProjectArtifacts.markableForBackups([modules], excludedFromAbove: [modules.url]).isEmpty)
}