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.

Count work in a folder named like one of the project's artifacts

Țugui Dragoșa6766370c9dc
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 7b33d518..18390ada 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -1198,7 +1198,7 @@ public enum ProjectArtifacts {
sawAnything = true
let name = url.lastPathComponent
let relative = String(key(of: url).dropFirst(base.count + 1))
- if artifacts.contains(name) || artifacts.contains(relative) || passedByForActivity.contains(name) {
+ if artifacts.contains(relative) || passedByForActivity.contains(name) {
// `skipDescendants()` after a file, such as a submodule's `.git`, would skip the next folder.
if (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == true {
enumerator.skipDescendants()
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index 1c7abd7c..ff83c9e7 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -1436,6 +1436,21 @@ struct ProjectArtifactsTests {
#expect(cache.isRecommended)
}
+ @Test func countsWorkInAFolderNamedLikeAnArtifactOfTheProject() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("app/build.gradle", bytes: 16)
+ try directory.file("app/.gradle/8.10/fileHashes/fileHashes.bin", bytes: 400_000)
+ try directory.file("app/build/classes/Tool.class", bytes: 400_000)
+ try directory.file("app/src/main/java/com/acme/build/Tool.java", bytes: 16)
+ try age(directory.url, days: 60)
+ let work = directory.url.appending(path: "app/src/main/java/com/acme/build/Tool.java").path(percentEncoded: false)
+ try FileManager.default.setAttributes([.modificationDate: Date.now], ofItemAtPath: work)
+
+ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts
+
+ #expect(try #require(found.first { $0.name == ".gradle" }).isRecentlyActive)
+ }
+
/// Work in a hidden file, in `.github`, or in a folder of the person's own that a tool's table also names is
/// work: only the artifacts found and what installed packages bring along are passed by.
@Test func countsWorkInHiddenFilesAndFoldersNamedLikeArtifacts() async throws {