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.

Offer only what carthage build makes in a Carthage project

Țugui Dragoșdc406e58730e
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index aa0afffd..f5e79bc9 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -161,9 +161,11 @@ public enum ProjectArtifacts {
name: "Pods", markers: ["Podfile"], tool: "CocoaPods", isGeneric: false,
source: "https://guides.cocoapods.org/using/using-cocoapods.html"
),
+ // Only what `carthage build` makes: `Carthage/Checkouts` holds the dependencies' source, which people commit
+ // in and, with `--use-submodules`, change.
Definition(
- name: "Carthage", markers: ["Cartfile"], tool: "Carthage", isGeneric: false,
- source: "https://github.com/Carthage/Carthage/blob/e33e133a5427129b38bfb1ae18d8f56b29a93204/README.md"
+ name: "Carthage/Build", markers: ["Cartfile"], tool: "Carthage", isGeneric: false,
+ source: "https://github.com/Carthage/Carthage/blob/e33e133a5427129b38bfb1ae18d8f56b29a93204/Documentation/Artifacts.md"
),
Definition(
name: "DerivedData", markers: ["*.xcodeproj", "*.xcworkspace"], tool: "Xcode", isGeneric: false,
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index 04ad4c31..fc88ea86 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -385,14 +385,26 @@ struct ProjectArtifactsTests {
#expect(found.first?.isRecommended == true)
}
- /// What may exist nowhere else is never selected: a clone someone commits in, as Carthage's checkouts are with
- /// `--use-submodules`, or a wallet. A repository inside a folder its tool tags as a cache is the tool's own
- /// clone, which it makes again, as Swift Package Manager does for `.build`.
+ @Test func carthageOffersItsBuildAndNeverItsCheckouts() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("Projects/app/Cartfile", bytes: 16)
+ try directory.file("Projects/app/Carthage/Build/Dep.xcframework/Info.plist", bytes: 16)
+ try directory.file("Projects/app/Carthage/Checkouts/Dep/Sources/Dep.swift", bytes: 16)
+ try directory.file("Projects/kit/Cartfile", bytes: 16)
+ try directory.file("Projects/kit/Carthage/Checkouts/Dep/.git", bytes: 16)
+ try age(directory.url, days: 60)
+
+ let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Projects")]).artifacts
+
+ #expect(found.map { "\($0.project.lastPathComponent)/\($0.name)" } == ["app/Carthage/Build"])
+ #expect(found.first?.isRecommended == true)
+ }
+
+ /// What may exist nowhere else is never selected: a repository, or a wallet. A repository inside a folder its
+ /// tool tags as a cache is the tool's own clone, which it makes again, as Swift Package Manager does for `.build`.
@Test func anArtifactHoldingARepositoryOrAWalletIsNotSelected() async throws {
let directory = try TemporaryDirectory()
let tag = Data("Signature: 8a477f597d28d172789f06886806bc55\n# a cache directory tag\n".utf8)
- try directory.file("Projects/app/Cartfile", bytes: 16)
- try directory.file("Projects/app/Carthage/Checkouts/Dep/.git/HEAD", bytes: 16)
try directory.file("Projects/site/package.json", bytes: 16)
try directory.file("Projects/site/node_modules/coin/wallet.dat", bytes: 16)
try directory.file("Projects/tool/Package.swift", bytes: 16)
@@ -406,7 +418,7 @@ struct ProjectArtifactsTests {
let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Projects")]).artifacts
let reasons = found.map { "\($0.project.lastPathComponent): \($0.heldBack.map(\.rawValue) ?? "none")" }.sorted()
- #expect(reasons == ["app: holdsRepository", "old: holdsRepository", "site: holdsAWallet", "tool: none"])
+ #expect(reasons == ["old: holdsRepository", "site: holdsAWallet", "tool: none"])
#expect(found.filter(\.isRecommended).map(\.project.lastPathComponent) == ["tool"])
}
diff --git a/SAFETY.md b/SAFETY.md
index 659ae8a2..65a9bcf1 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -248,8 +248,8 @@ tool tags as a cache (`CACHEDIR.TAG`): Swift Package Manager tags `.build`, wher
dependencies, and `swift package reset` deletes that folder whole, so Build Artifacts can still select it. The other
is a cache on the Developer page, a folder its tool's documentation or source shows to be a cache, such as the
packages Xcode checks out into DerivedData or the clones Cargo and Swift Package Manager keep, which the tool clones
-again when it needs them. Carthage's checkouts in a project, which people commit in, carry no such tag and are never
-selected.
+again when it needs them. Of Carthage's folder in a project, only `Carthage/Build`, which `carthage build` makes, is
+offered: its checkouts, which people commit in, carry no such tag and are never listed.
Build Artifacts selects what a build or a package manager makes again from the project's own files, such as
`DerivedData`, `.build`, and `.next`, once Peel can tell that nothing in the project has changed for a week. That