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.

Give Git and Homebrew the home without the slash at its end

Țugui Dragoșee2660a960b7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c7400c57..25cfe0fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -717,6 +717,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- History names a Forget entry after the casks whose record moved, not every cask chosen.
- Going to another page while a cask's apps quit no longer gives up the upgrade or the uninstall.
- Check Health no longer says `sbin` is missing from your PATH for a Homebrew in `/usr/local`.
+- What Homebrew prints names the folders in your home with one slash, not `//`, as in its downloads' folder.
- With `HOMEBREW_NO_AUTOREMOVE` set, Uninstall and Clean Up no longer promise to remove formulae nothing needs, and the
page names the setting.
- A Homebrew of root's, or a Cellar this account can't write, is named with the folder that stops it and the command
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index e7eaeff4..e0f9b3bb 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -1480,7 +1480,7 @@ public enum Homebrew {
}
var values = [
"PATH": path,
- "HOME": home.path(percentEncoded: false),
+ "HOME": home.pathAsHOME,
"HOMEBREW_NO_ENV_HINTS": "1",
// Without this every call pings Homebrew's analytics over the network.
"HOMEBREW_NO_ANALYTICS": "1",
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/HomeForPrograms.swift b/Packages/PeelCore/Sources/PeelCore/Support/HomeForPrograms.swift
new file mode 100644
index 00000000..03e6608c
--- /dev/null
+++ b/Packages/PeelCore/Sources/PeelCore/Support/HomeForPrograms.swift
@@ -0,0 +1,9 @@
+import Foundation
+
+extension URL {
+ /// The home as the programs Peel runs get it in `HOME`: with no slash at the end, which `"$HOME/.gitconfig"` would
+ /// double in what they say.
+ var pathAsHOME: String {
+ (path(percentEncoded: false) as NSString).standardizingPath
+ }
+}
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/GitConfig.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/GitConfig.swift
index c66cb9ea..4bc4f7a1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/GitConfig.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/GitConfig.swift
@@ -132,7 +132,7 @@ public struct GitConfig: Sendable {
await Subprocess.run(
executable.path(percentEncoded: false),
arguments,
- environment: ["HOME": home.path(percentEncoded: false), "PATH": "/usr/bin:/bin:/usr/sbin:/sbin"],
+ environment: ["HOME": home.pathAsHOME, "PATH": "/usr/bin:/bin:/usr/sbin:/sbin"],
timeout: 10
)
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
index db17be77..f634ad81 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellSessions.swift
@@ -46,9 +46,8 @@ public enum ShellSessions: Sendable, Equatable {
func zshrc(home: URL, zdotdir: String?) async -> URL? {
guard case .zsh(let zshenv) = self else { return nil }
let folder = zshenv.deletingLastPathComponent()
- // With no slash at the end, which `"$HOME/.config/zsh"` would double.
var environment = [
- "HOME": (home.path(percentEncoded: false) as NSString).standardizingPath,
+ "HOME": home.pathAsHOME,
"PATH": "/usr/bin:/bin:/usr/sbin:/sbin",
]
if let zdotdir, !zdotdir.isEmpty {
@@ -88,7 +87,7 @@ public enum ShellSessions: Sendable, Equatable {
func promptShown(home: URL, zdotdir: String?) async -> ShownPrompt? {
guard case .zsh = self else { return nil }
var environment = [
- "HOME": (home.path(percentEncoded: false) as NSString).standardizingPath,
+ "HOME": home.pathAsHOME,
"PATH": "/usr/bin:/bin:/usr/sbin:/sbin",
"TERM": "xterm-256color",
]
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/GitSettingsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/GitSettingsTests.swift
index a364743f..1d6951ef 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/GitSettingsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/GitSettingsTests.swift
@@ -185,6 +185,7 @@ struct GitSettingsTests {
return
}
#expect(words.hasPrefix("error: could not lock config file"), "\(words)")
+ #expect(!words.contains("//"), "Git names the file from the home it was given: \(words)")
#expect(handed == [["pull.rebase": "true"], [:]])
#expect(ledger.written.isEmpty && ledger.previous.isEmpty)
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
index 5745ee07..13c4748e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
@@ -39,6 +39,11 @@ struct HomebrewTests {
}
}
+ @Test func givesHomebrewTheHomeWithoutTheSlashAtItsEnd() {
+ let home = URL(filePath: "/Users/someone/", directoryHint: .isDirectory)
+ #expect(Homebrew.environment(autoUpdate: false, home: home)["HOME"] == "/Users/someone")
+ }
+
@Test func asksForEachLineAsItGoesExceptOfTheHealthCheck() {
#expect(Homebrew.environment(autoUpdate: false)["CI"] == "1")
// `brew doctor` reads `CI` as a CI run and skips its check of the taps' branches (`diagnostic.rb`).