Skip to content

Commit 6c9c48a

Browse files
Fix lint
1 parent b9d3945 commit 6c9c48a

11 files changed

+482
-472
lines changed

CodeEdit/Features/LSP/Registry/PackageManagers/GithubPackageManager.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ class GithubPackageManager: PackageManagerProtocol {
4040
switch method {
4141
case let .binaryDownload(source, url):
4242
try await downloadBinary(source, url)
43-
break
4443
case let .sourceBuild(source, command):
4544
try await installFromSource(source, command)
46-
break
47-
case .standardPackage(_), .unknown:
45+
case .standardPackage, .unknown:
4846
throw PackageManagerError.invalidConfiguration
4947
}
5048
}
@@ -67,7 +65,7 @@ class GithubPackageManager: PackageManagerProtocol {
6765
}
6866

6967
private func downloadBinary(_ source: PackageSource, _ url: URL) async throws {
70-
let (data, _) = try await URLSession.shared.data(from: url)
68+
_ = try await URLSession.shared.data(from: url)
7169
let fileName = url.lastPathComponent
7270
let downloadPath = installationDirectory.appending(path: source.name)
7371
let packagePath = downloadPath.appending(path: fileName)

CodeEdit/Features/LSP/Registry/PackageManagers/GolangPackageManager.swift

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,7 @@ class GolangPackageManager: PackageManagerProtocol {
5151
let gobinPath = packagePath.appending(path: "bin", directoryHint: .isDirectory).path
5252
var goInstallCommand = ["env", "GOBIN=\(gobinPath)", "go", "install"]
5353

54-
if let gitRef = source.gitReference, let repoUrl = source.repositoryUrl {
55-
// Check if this is a Git-based package
56-
var packageName = source.name
57-
if !packageName.contains("github.com") && !packageName.contains("golang.org") {
58-
packageName = repoUrl.replacingOccurrences(of: "https://", with: "")
59-
}
60-
61-
var gitVersion: String
62-
switch gitRef {
63-
case .tag(let tag):
64-
gitVersion = tag
65-
case .revision(let rev):
66-
gitVersion = rev
67-
}
68-
69-
goInstallCommand.append("\(packageName)@\(gitVersion)")
70-
} else {
71-
goInstallCommand.append("\(source.name)@\(source.version)")
72-
}
54+
goInstallCommand.append(getGoInstallCommand(source))
7355
_ = try await executeInDirectory(in: packagePath.path, goInstallCommand)
7456

7557
// If there's a subpath, build the binary
@@ -152,4 +134,26 @@ class GolangPackageManager: PackageManagerProtocol {
152134
line.contains(dependencyPath)
153135
}
154136
}
137+
138+
private func getGoInstallCommand(_ source: PackageSource) -> String {
139+
if let gitRef = source.gitReference, let repoUrl = source.repositoryUrl {
140+
// Check if this is a Git-based package
141+
var packageName = source.name
142+
if !packageName.contains("github.com") && !packageName.contains("golang.org") {
143+
packageName = repoUrl.replacingOccurrences(of: "https://", with: "")
144+
}
145+
146+
var gitVersion: String
147+
switch gitRef {
148+
case .tag(let tag):
149+
gitVersion = tag
150+
case .revision(let rev):
151+
gitVersion = rev
152+
}
153+
154+
return "\(packageName)@\(gitVersion)"
155+
} else {
156+
return "\(source.name)@\(source.version)"
157+
}
158+
}
155159
}

0 commit comments

Comments
 (0)