Skip to content

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

Merged
merged 2 commits into from
Nov 19, 2020

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Nov 19, 2020

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

to be merged after #3068

@tomerd tomerd requested review from yim-lee and removed request for aciidgh November 19, 2020 03:45
@@ -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()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👀 @neonichu

@tomerd tomerd self-assigned this Nov 19, 2020
@tomerd tomerd mentioned this pull request Nov 19, 2020
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
@tomerd tomerd force-pushed the feature/package-collections-8 branch from dd14382 to 347880c Compare November 19, 2020 05:19
@tomerd
Copy link
Contributor Author

tomerd commented Nov 19, 2020

@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)
Copy link
Contributor

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)")
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@tomerd tomerd merged commit 460eba1 into swiftlang:main Nov 19, 2020
@@ -67,6 +70,7 @@ extension PackageCollectionsModel {
init(
repository: RepositorySpecifier,
description: String?,
keywords: [String]?,
Copy link
Contributor

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?

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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?

federicobucchi pushed a commit to federicobucchi/swift-package-manager that referenced this pull request Jan 6, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants