Skip to content

Commit 43174e9

Browse files
committed
~ Internals of package names
1 parent f59e315 commit 43174e9

File tree

54 files changed

+256
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+256
-197
lines changed

Cork/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ private extension View
660660
shouldRemoveAllAssociatedFiles: false
661661
)
662662
} label: {
663-
Text("action.uninstall-\(packageToUninstall.name)")
663+
Text("action.uninstall-\(packageToUninstall.getPackageName(withPrecision: .precise))")
664664
}
665665
.keyboardShortcut(.defaultAction)
666666
.asyncButtonStyle(.plainStyle)
@@ -676,7 +676,7 @@ private extension View
676676
shouldRemoveAllAssociatedFiles: true
677677
)
678678
} label: {
679-
Text("action.purge-\(packageToPurge.name)")
679+
Text("action.purge-\(packageToPurge.getPackageName(withPrecision: .precise))")
680680
}
681681
}
682682
}, message: { dialogType in

Cork/CorkApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ struct CorkApp: App
706706
let differentPackages: Set<OutdatedPackage> = await newOutdatedPackages.subtracting(outdatedPackagesTracker.allDisplayableOutdatedPackages)
707707
AppConstants.shared.logger.debug("Changed packages: \(differentPackages, privacy: .auto)")
708708

709-
sendNotification(title: String(localized: "notification.new-outdated-packages-found.title"), subtitle: differentPackages.map{$0.package.name}.formatted(.list(type: .and)))
709+
sendNotification(title: String(localized: "notification.new-outdated-packages-found.title"), subtitle: differentPackages.map{$0.package.getPackageName(withPrecision: .precise)}.formatted(.list(type: .and)))
710710

711711
await outdatedPackagesTracker.setOutdatedPackages(to: newOutdatedPackages)
712712

Cork/Logic/App Intents/Currently Installed Packages/Get Installed Casks Intent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct GetInstalledCasksIntent: AppIntent
4949

5050
let minimalPackages: [MinimalHomebrewPackage] = validInstalledCasks.map
5151
{ package in
52-
.init(name: package.name, type: .cask, installDate: package.installedOn, installedIntentionally: true)
52+
.init(name: package.getPackageName(withPrecision: .precise), type: .cask, installDate: package.installedOn, installedIntentionally: true)
5353
}
5454

5555
return .result(value: minimalPackages)

Cork/Logic/App Intents/Currently Installed Packages/Get Installed Formulae Intent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct GetInstalledFormulaeIntent: AppIntent
6363

6464
var minimalPackages: [MinimalHomebrewPackage] = validInstalledFormulae.map
6565
{ package in
66-
.init(name: package.name, type: .formula, installedIntentionally: package.installedIntentionally)
66+
.init(name: package.getPackageName(withPrecision: .precise), type: .formula, installedIntentionally: package.installedIntentionally)
6767
}
6868

6969
if getOnlyManuallyInstalledPackages

Cork/Models/Package Installation/Installation Progress Tracker.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ class InstallationProgressTracker
4545
{
4646
let package: BrewPackage = packageBeingInstalled.package
4747

48-
AppConstants.shared.logger.debug("Installing package \(package.name, privacy: .auto)")
48+
AppConstants.shared.logger.debug("Installing package \(package.getPackageName(withPrecision: .precise), privacy: .auto)")
4949

5050
var installationResult: TerminalOutput = .init(standardOutput: "", standardError: "")
5151

5252
if package.type == .formula
5353
{
54-
AppConstants.shared.logger.info("Package \(package.name, privacy: .public) is Formula")
54+
AppConstants.shared.logger.info("Package \(package.getPackageName(withPrecision: .precise), privacy: .public) is Formula")
5555

5656
let output: String = try await installFormula(using: brewPackagesTracker).joined(separator: "")
5757

@@ -88,9 +88,9 @@ class InstallationProgressTracker
8888
var hasAlreadyMatchedLineAboutInstallingPackageItself: Bool = false
8989
var installOutput: [String] = .init()
9090

91-
AppConstants.shared.logger.info("Package \(package.name, privacy: .public) is Formula")
91+
AppConstants.shared.logger.info("Package \(package.getPackageName(withPrecision: .precise), privacy: .public) is Formula")
9292

93-
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name])
93+
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.getPackageName(withPrecision: .precise)])
9494
installationProcess = process
9595
for await output in stream
9696
{
@@ -110,7 +110,7 @@ class InstallationProgressTracker
110110
if outputLine.contains("Fetching dependencies")
111111
{
112112
// First, we have to get a list of all the dependencies
113-
var matchedDependencies: String = try outputLine.regexMatch("(?<=\(package.name): ).*?(.*)")
113+
var matchedDependencies: String = try outputLine.regexMatch("(?<=\(package.getPackageName(withPrecision: .precise)): ).*?(.*)")
114114
matchedDependencies = matchedDependencies.replacingOccurrences(of: " and", with: ",") // The last dependency is different, because it's preceded by "and" instead of "," so let's replace that "and" with "," so we can split it nicely
115115

116116
AppConstants.shared.logger.debug("Matched Dependencies: \(matchedDependencies, privacy: .auto)")
@@ -126,7 +126,7 @@ class InstallationProgressTracker
126126
packageBeingInstalled.packageInstallationProgress = 1
127127
}
128128

129-
else if outputLine.contains("Installing dependencies") || outputLine.contains("Installing \(package.name) dependency")
129+
else if outputLine.contains("Installing dependencies") || outputLine.contains("Installing \(package.getPackageName(withPrecision: .precise)) dependency")
130130
{
131131
AppConstants.shared.logger.info("Will install dependencies!")
132132
packageBeingInstalled.installationStage = .installingDependencies
@@ -151,7 +151,7 @@ class InstallationProgressTracker
151151
packageBeingInstalled.packageInstallationProgress = packageBeingInstalled.packageInstallationProgress + Double(Double(10) / (Double(3) * (Double(numberOfPackageDependencies) * Double(5))))
152152
}
153153

154-
else if outputLine.contains("Fetching \(package.name)") || outputLine.contains("Installing \(package.name)")
154+
else if outputLine.contains("Fetching \(package.getPackageName(withPrecision: .precise))") || outputLine.contains("Installing \(package.getPackageName(withPrecision: .precise))")
155155
{
156156
if hasAlreadyMatchedLineAboutInstallingPackageItself
157157
{ /// Only the second line about the package being installed is valid
@@ -205,9 +205,9 @@ class InstallationProgressTracker
205205
let package: BrewPackage = packageBeingInstalled.package
206206

207207
AppConstants.shared.logger.info("Package is Cask")
208-
AppConstants.shared.logger.debug("Installing package \(package.name, privacy: .public)")
208+
AppConstants.shared.logger.debug("Installing package \(package.getPackageName(withPrecision: .precise), privacy: .public)")
209209

210-
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.name])
210+
let (stream, process): (AsyncStream<StreamedTerminalOutput>, Process) = shell(AppConstants.shared.brewExecutablePath, ["install", package.getPackageName(withPrecision: .precise)])
211211
installationProcess = process
212212
for await output in stream
213213
{
@@ -255,7 +255,7 @@ class InstallationProgressTracker
255255
}
256256
else if outputLine.contains("Purging files")
257257
{
258-
AppConstants.shared.logger.info("Purging old version of cask \(package.name)")
258+
AppConstants.shared.logger.info("Purging old version of cask \(package.getPackageName(withPrecision: .precise))")
259259

260260
packageBeingInstalled.installationStage = .installingCask
261261

Cork/Views/Installation/Reusables/Search Result Row.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ struct SearchResultRow: View, Sendable
4949
case .searchResults:
5050
if searchedForPackage.type == .formula
5151
{
52-
if brewPackagesTracker.successfullyLoadedFormulae.contains(where: { $0.name == searchedForPackage.name })
52+
if brewPackagesTracker.successfullyLoadedFormulae.contains(where: { $0.getCompletePackageName() == searchedForPackage.getCompletePackageName() })
5353
{
5454
PillTextWithLocalizableText(localizedText: "add-package.result.already-installed")
5555
}
5656
}
5757
else
5858
{
59-
if brewPackagesTracker.successfullyLoadedCasks.contains(where: { $0.name == searchedForPackage.name })
59+
if brewPackagesTracker.successfullyLoadedCasks.contains(where: { $0.getCompletePackageName() == searchedForPackage.getCompletePackageName() })
6060
{
6161
PillTextWithLocalizableText(localizedText: "add-package.result.already-installed")
6262
}
@@ -114,7 +114,7 @@ struct SearchResultRow: View, Sendable
114114
{
115115
if showDescriptionsInSearchResults
116116
{
117-
AppConstants.shared.logger.info("\(searchedForPackage.name, privacy: .auto) came into view")
117+
AppConstants.shared.logger.info("\(searchedForPackage.getPackageName(withPrecision: .precise), privacy: .auto) came into view")
118118

119119
if description == nil
120120
{
@@ -123,11 +123,11 @@ struct SearchResultRow: View, Sendable
123123
isLoadingDescription = false
124124
}
125125

126-
AppConstants.shared.logger.info("\(searchedForPackage.name, privacy: .auto) does not have its description loaded")
126+
AppConstants.shared.logger.info("\(searchedForPackage.getPackageName(withPrecision: .precise), privacy: .auto) does not have its description loaded")
127127

128128
do
129129
{
130-
let searchedForPackage: BrewPackage = .init(name: searchedForPackage.name, type: searchedForPackage.type, installedOn: Date(), versions: [], url: nil, sizeInBytes: nil, downloadCount: nil)
130+
let searchedForPackage: BrewPackage = .init(name: searchedForPackage.getPackageName(withPrecision: .precise), type: searchedForPackage.type, installedOn: Date(), versions: [], url: nil, sizeInBytes: nil, downloadCount: nil)
131131

132132
do
133133
{
@@ -147,7 +147,7 @@ struct SearchResultRow: View, Sendable
147147
}
148148
else
149149
{
150-
AppConstants.shared.logger.info("\(searchedForPackage.name, privacy: .auto) already has its description loaded")
150+
AppConstants.shared.logger.info("\(searchedForPackage.getPackageName(withPrecision: .precise), privacy: .auto) already has its description loaded")
151151
}
152152
}
153153
}

Cork/Views/Installation/Sub-Views/Initial.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct InstallationInitialView: View
111111
}
112112

113113
openWindow(value: MinimalHomebrewPackage(
114-
name: packageToPreview.name,
114+
name: packageToPreview.getPackageName(withPrecision: .precise),
115115
type: packageToPreview.type,
116116
installedIntentionally: packageToPreview.installedIntentionally
117117
))
@@ -134,7 +134,7 @@ struct InstallationInitialView: View
134134

135135
installationProgressTracker.packageBeingInstalled = PackageInProgressOfBeingInstalled(package: packageToInstall, installationStage: .ready, packageInstallationProgress: 0)
136136

137-
AppConstants.shared.logger.debug("Packages to install: \(installationProgressTracker.packageBeingInstalled.package.name, privacy: .public)")
137+
AppConstants.shared.logger.debug("Packages to install: \(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise), privacy: .public)")
138138

139139
packageInstallationProcessStep = .installing
140140

Cork/Views/Installation/Sub-Views/Initial/Top Packages Section.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ struct TopPackagesSection: View
2525
case .formula:
2626
packageTracker.sortedTopFormulae.filter
2727
{
28-
!brewPackagesTracker.successfullyLoadedFormulae.map(\.name).contains($0.name)
28+
!brewPackagesTracker.successfullyLoadedFormulae.map{$0.getCompletePackageName()}.contains($0.getCompletePackageName())
2929
}
3030
case .cask:
3131
packageTracker.sortedTopCasks.filter
3232
{
33-
!brewPackagesTracker.successfullyLoadedCasks.map(\.name).contains($0.name)
33+
!brewPackagesTracker.successfullyLoadedCasks.map{$0.getCompletePackageName()}.contains($0.getCompletePackageName())
3434
}
3535
}
3636
}

Cork/Views/Installation/Sub-Views/Installing.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@ struct InstallingPackageView: View
5858

5959
// CASKS
6060
case .downloadingCask:
61-
Text("add-package.install.downloading-cask-\(installationProgressTracker.packageBeingInstalled.package.name)")
61+
Text("add-package.install.downloading-cask-\(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise))")
6262

6363
case .installingCask:
64-
Text("add-package.install.installing-cask-\(installationProgressTracker.packageBeingInstalled.package.name)")
64+
Text("add-package.install.installing-cask-\(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise))")
6565

6666
case .linkingCaskBinary:
6767
Text("add-package.install.linking-cask-binary")
6868

6969
case .movingCask:
70-
Text("add-package.install.moving-cask-\(installationProgressTracker.packageBeingInstalled.package.name)")
70+
Text("add-package.install.moving-cask-\(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise))")
7171

7272
case .requiresSudoPassword:
73-
Text("add-package.install.requires-sudo-password-\(installationProgressTracker.packageBeingInstalled.package.name)")
73+
Text("add-package.install.requires-sudo-password-\(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise))")
7474
.onAppear
7575
{
7676
packageInstallationProcessStep = .requiresSudoPassword
@@ -84,7 +84,7 @@ struct InstallingPackageView: View
8484
}
8585

8686
case .binaryAlreadyExists:
87-
Text("add-package.install.binary-already-exists-\(installationProgressTracker.packageBeingInstalled.package.name)")
87+
Text("add-package.install.binary-already-exists-\(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise))")
8888
.onAppear
8989
{
9090
packageInstallationProcessStep = .binaryAlreadyExists

Cork/Views/Installation/Sub-Views/Presenting Search Results.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ struct PresentingSearchResultsView: View
122122
return
123123
}
124124
openWindow(value: MinimalHomebrewPackage(
125-
name: selectedPackage.name,
125+
name: selectedPackage.getPackageName(withPrecision: .precise),
126126
type: selectedPackage.type,
127127
installedIntentionally: selectedPackage.installedIntentionally
128128
))
129129

130-
AppConstants.shared.logger.debug("Would preview package \(selectedPackage.name)")
130+
AppConstants.shared.logger.debug("Would preview package \(selectedPackage.getPackageName(withPrecision: .precise))")
131131
}
132132
.disabled(foundPackageSelection == nil)
133133
.labelStyle(.titleOnly)
@@ -179,7 +179,7 @@ struct PresentingSearchResultsView: View
179179
installationProgressTracker.packageBeingInstalled = PackageInProgressOfBeingInstalled(package: foundPackageSelection, installationStage: .ready, packageInstallationProgress: 0)
180180

181181
#if DEBUG
182-
AppConstants.shared.logger.info("Packages to install: \(installationProgressTracker.packageBeingInstalled.package.name, privacy: .public)")
182+
AppConstants.shared.logger.info("Packages to install: \(installationProgressTracker.packageBeingInstalled.package.getPackageName(withPrecision: .precise), privacy: .public)")
183183
#endif
184184
}
185185
}

0 commit comments

Comments
 (0)