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.

Name History's write check as the code does, and check every name a document gives

Țugui Dragoș9d9ba33178af
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index f574b4d4..2f328dfa 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -184,7 +184,8 @@ the Homebrew page's uninstall and cleanups are Homebrew's own.
through Control-C (`Uninterrupted`).
- While History cannot be read nothing moves (`RemovalLog.canBeRead`, asked by `TrashService` before a removal)
until Start Over, on the History page, sets the unreadable file aside, and while it cannot be written, its folder
- closed or its disk without room for the copy a safe write makes, nothing moves either (`RemovalLog.canBeWritten`).
+ closed, its disk without room for the copy a safe write makes or silent about its free space, or the journal
+ beside it unusable, nothing moves either, and Peel says which (`RemovalLog.writeProblem`).
- What Peel refused to move is recorded too (`refusals.json`), and History lists it under Not Moved, one
removal to an entry, the latest 5,000 items at most, leaving the oldest out whole and counting them in
`totals.json`, so its page and `peel history --refused` say how many.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
index cdfc148c..7f33adac 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
@@ -134,14 +134,22 @@ struct DocumentationTests {
#expect(Self.words(in: #"let tag = "CACHEDIR.TAG" // BrowserWallets.swift"#).isSuperset(of: ["CACHEDIR", "BrowserWallets"]))
}
- @Test func readsTheTypeAPathOrACallStartsWith() {
- let text = "`TrashService`, `RemovalLog.canBeRead`, `Homebrew.overrides()`, `peel`, `HOMEBREW_NO_AUTO_UPDATE`"
- #expect(Self.names(in: text) == ["TrashService", "RemovalLog", "Homebrew"])
+ @Test func readsEveryNameOfAPathOrACall() {
+ let text = "`TrashService`, `RemovalLog.canBeRead`, `Homebrew.overrides()`, `TrashService.trash(apps:thenFiles:)`, "
+ + "`peel`, `HOMEBREW_NO_AUTO_UPDATE`"
+ #expect(
+ Self.names(in: text)
+ == ["TrashService", "RemovalLog", "canBeRead", "Homebrew", "overrides", "TrashService", "trash"]
+ )
}
+ /// Every name of a type, a path through it, or a call, its labels left out, so a member renamed in the code is
+ /// found as well as a type.
static func names(in text: String) -> [String] {
- let name = try! Regex(#"`([A-Z][A-Za-z0-9]+)(?:\.[A-Za-z0-9_]+)*(?:\(\))?`"#, as: (Substring, Substring).self)
- return text.matches(of: name).map { String($0.output.1) }
+ let name = try! Regex(
+ #"`([A-Z][A-Za-z0-9]+(?:\.[A-Za-z_][A-Za-z0-9_]*)*)(?:\([^`()]*\))?`"#, as: (Substring, Substring).self
+ )
+ return text.matches(of: name).flatMap { $0.output.1.split(separator: ".").map(String.init) }
}
static func code() throws -> String {