Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Date a worktree or a submodule by Git's marks too
Țugui Dragoș717aa9d92e97
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/GitIndex.swift b/Packages/PeelCore/Sources/PeelCore/Developer/GitIndex.swiftindex 79207f78..758e6108 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/GitIndex.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/GitIndex.swift@@ -40,7 +40,7 @@ struct GitIndex: Sendable {return nil}- private static func gitDirectory(at dotGit: URL) -> URL? {+ static func gitDirectory(at dotGit: URL) -> URL? {var info = stat()guard stat(dotGit.path(percentEncoded: false), &info) == 0 else { return nil }switch info.st_mode & S_IFMT {diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex a2f7e344..d860b329 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -1330,8 +1330,9 @@ public enum ProjectArtifacts {return definitions.contains { $0.name == name && !$0.isGeneric }}- /// Files Git updates whenever the repository changes: three reads can answer for a whole repository.- private static let gitMarks = [".git/index", ".git/HEAD", ".git/logs/HEAD"]+ /// Files Git updates whenever the repository changes: three reads can answer for a whole repository. A worktree or+ /// a submodule keeps them in the folder its `.git` file names.+ private static let gitMarks = ["index", "HEAD", "logs/HEAD"]/// What the read of a project's last change passes by besides its artifacts: Git's own store, which its marks/// answer for, and installed packages, which change when they are installed rather than when anyone works.@@ -1345,9 +1346,9 @@ public enum ProjectArtifacts {) -> (date: Date?, isCertain: Bool) {let cutoff = Date.now.addingTimeInterval(-recentlyActive)var newest: Date?- for mark in gitMarks {- let url = project.appending(path: mark)- guard let date = try? url.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate+ let gitDirectory = GitIndex.gitDirectory(at: project.appending(path: ".git"))+ for mark in gitDirectory.map({ directory in gitMarks.map { directory.appending(path: $0) } }) ?? [] {+ guard let date = try? mark.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDateelse { continue }if newest == nil || date > newest! { newest = date }if date > cutoff { return (date, true) }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 118c896d..e4209d46 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -1526,6 +1526,26 @@ struct ProjectArtifactsTests {#expect(scan.refusedRoots.map(\.reason) == [.notAFolder])}+ @Test func aWorktreeOrASubmoduleIsDatedByGitsMarksToo() throws {+ let directory = try TemporaryDirectory()+ try directory.file("main/.git/worktrees/feature/HEAD")+ try directory.file("feature/.git", contents: Data("gitdir: ../main/.git/worktrees/feature\n".utf8))+ try directory.file("feature/source.c")+ try age(directory.url.appending(path: "feature"), days: 60)+ let git = directory.url.appending(path: "main/.git/worktrees/feature/HEAD")+ let anHourAgo = Date.now.addingTimeInterval(-3_600)+ try FileManager.default.setAttributes(+ [.modificationDate: anHourAgo], ofItemAtPath: git.path(percentEncoded: false)+ )++ let activity = ProjectArtifacts.lastActivity(+ in: directory.url.appending(path: "feature", directoryHint: .isDirectory), ignoring: []+ )++ #expect(activity.isCertain)+ #expect(activity.date.map { abs($0.timeIntervalSince(anHourAgo)) < 2 } == true)+ }+@Test func aFolderOfEnvironmentsKnownOnlyByItsTagIsNoCache() async throws {let directory = try TemporaryDirectory()let tag = Data("Signature: 8a477f597d28d172789f06886806bc55\n".utf8)