Skip to content

integrate registry dependencies into dependency resolution #3873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ let package = Package(
"Basics",
"PackageGraph",
"PackageLoading",
"PackageRegistry",
"SourceControl",
.product(name: "TSCTestSupport", package: "swift-tools-support-core"),
"Workspace",
Expand Down
6 changes: 5 additions & 1 deletion Sources/Basics/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ public struct HTTPClientResponse {

extension HTTPClientResponse {
public static func okay(body: String? = nil) -> HTTPClientResponse {
return HTTPClientResponse(statusCode: 200, body: body?.data(using: .utf8))
return .okay(body: body?.data(using: .utf8))
}

public static func okay(body: Data?) -> HTTPClientResponse {
return HTTPClientResponse(statusCode: 200, body: body)
}

public static func notFound(reason: String? = nil) -> HTTPClientResponse {
Expand Down
4 changes: 1 addition & 3 deletions Sources/Commands/SwiftPackageRegistryTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public struct SwiftPackageRegistryTool: ParsableCommand {
var url: String

func run(_ swiftTool: SwiftTool) throws {
guard let url = URL(string: self.url),
url.scheme == "https"
else {
guard let url = URL(string: self.url), url.scheme == "https" else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safer to do case-insensitive compare

throw RegistryConfigurationError.invalidURL(self.url)
}

Expand Down
5 changes: 2 additions & 3 deletions Sources/PackageGraph/PackageGraph+Loading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ private func createResolvedPackages(
case .remote(let url):
dependencyLocation = url.absoluteString
}
case .registry:
// FIXME
fatalError("registry based dependencies not implemented yet")
case .registry(let settings):
dependencyLocation = settings.identity.description
}

// Otherwise, look it up by its identity.
Expand Down
8 changes: 6 additions & 2 deletions Sources/PackageLoading/ToolsVersionLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,13 @@ public struct ToolsVersionLoader: ToolsVersionLoaderProtocol {
guard let manifestContentsDecodedWithUTF8 = manifestContents.validDescription else {
throw Error.nonUTF8EncodedManifest(path: file)
}


return try self.load(utf8String: manifestContentsDecodedWithUTF8)
}

public func load(utf8String: String) throws -> ToolsVersion {
/// The manifest represented in its constituent parts.
let manifestComponents = ToolsVersionLoader.split(manifestContentsDecodedWithUTF8)
let manifestComponents = ToolsVersionLoader.split(utf8String)
/// The Swift tools version specification represented in its constituent parts.
let toolsVersionSpecificationComponents = manifestComponents.toolsVersionSpecificationComponents

Expand Down
6 changes: 3 additions & 3 deletions Sources/PackageModel/PackageIdentity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public struct PackageIdentity: CustomStringConvertible {
}

// TODO: formalize package registry identifier
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR: is this done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to take another look. will address in follow up PR of needs more attention, it works fine for the test cases I ran

public var scopeAndName: (Scope, Name)? {
public var scopeAndName: (scope: Scope, name: Name)? {
let components = description.split(separator: ".", maxSplits: 1, omittingEmptySubsequences: true)
guard components.count == 2,
let scope = Scope(components.first),
let name = Name(components.last)
else { return nil }
else { return .none }

return (scope, name)
return (scope: scope, name: name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageRegistry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
add_library(PackageRegistry
Registry.swift
RegistryConfiguration.swift
RegistryManager.swift
RegistryClient.swift
SourceArchiver.swift)
target_link_libraries(PackageRegistry PUBLIC
Basics
Expand Down
Loading