-
Notifications
You must be signed in to change notification settings - Fork 1.4k
simplify package collections model #3069
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
Conversation
@@ -18,7 +18,21 @@ public struct PackageCollections: PackageCollectionsProtocol { | |||
private let collectionProviders: [PackageCollectionsModel.CollectionSourceType: PackageCollectionProvider] | |||
private let metadataProvider: PackageMetadataProvider | |||
|
|||
init(configuration: Configuration, | |||
// initialize with defaults | |||
public init(configuration: Configuration = .init()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sources/PackageCollections/Providers/GitHubPackageMetadataProvider.swift
Show resolved
Hide resolved
Sources/PackageCollections/Providers/JSONPackageCollectionProvider.swift
Outdated
Show resolved
Hide resolved
Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift
Outdated
Show resolved
Hide resolved
Sources/PackageCollections/Storage/FilePackageCollectionsSourcesStorage.swift
Outdated
Show resolved
Hide resolved
motivation: simpler is nicer changes: * dedupe collection.package and package, and collection.package.version and pacakge.version as they ended up very similar * add keywords to package and package basic metadata * adjust code & tests
dd14382
to
347880c
Compare
@swift-ci please smoke test |
@@ -154,7 +157,8 @@ struct GitHubPackageMetadataProvider: PackageMetadataProvider { | |||
} | |||
|
|||
enum Errors: Error, Equatable { | |||
case unprocessable(PackageReference) | |||
case invalidReferenceType(PackageReference) | |||
case invalidGitUrl(String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: URL
@@ -127,7 +130,7 @@ struct GitHubPackageMetadataProvider: PackageMetadataProvider { | |||
let owner = String(url[ownerRange]) | |||
let repo = String(url[repoRange]) | |||
|
|||
return URL(string: "https://api.\(host)/\(owner)/\(repo)") | |||
return URL(string: "https://api.\(host)/repos/\(owner)/\(repo)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -67,6 +70,7 @@ extension PackageCollectionsModel { | |||
init( | |||
repository: RepositorySpecifier, | |||
description: String?, | |||
keywords: [String]?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a semantic distinction to an empty vs a nil collection of keywords, or is it mainly to avoid a coded entry for an empty collection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the latter
@@ -61,7 +61,9 @@ struct GitHubPackageMetadataProvider: PackageMetadataProvider { | |||
// get the main data | |||
sync.enter() | |||
let options = self.makeRequestOptions(validResponseCodes: [200]) | |||
httpClient.get(metadataURL, options: options) { result in | |||
var headers = HTTPClientHeaders() | |||
headers.add(name: "Accept", value: "application/vnd.github.mercy-preview+json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a literal string or something that should be parameterized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you asking about constants for the header name?
* simplify package collections model motivation: simpler is nicer changes: * dedupe collection.package and package, and collection.package.version and pacakge.version as they ended up very similar * add keywords to package and package basic metadata * adjust code & tests * fixup
motivation: simpler is nicer
changes:
to be merged after #3068