Skip to content

update collections APIs to use package identity #3743

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 3 commits into from
Sep 15, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Sep 14, 2021

motivation: adoption of SE-0292 package registry

chnages:

  • migrate APIs that take PackageRefernec to take PackageIdentity
  • adjust and update tests

rdar://83073308
rdar://82954076

@tomerd tomerd requested a review from yim-lee September 14, 2021 19:06
@tomerd tomerd force-pushed the refactor/package-location-03 branch from 5e89a8d to 4b88697 Compare September 14, 2021 19:07
motivation: adoption of SE-0292 package registry

chnages:
* migrate APIs that take PackageRefernec to take PackageIdentity
* adjust and update tests

rdar://83073308
rdar://82954076
@tomerd tomerd force-pushed the refactor/package-location-03 branch from 4b88697 to 5b7ed39 Compare September 14, 2021 19:08
@tomerd
Copy link
Contributor Author

tomerd commented Sep 14, 2021

@swift-ci please smoke test

/// Package's repository address
public let repository: RepositorySpecifier
/// Package location
public let location: String

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep reference and repository until folks switch over to identity and location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yim-lee on the Package model?

Copy link
Contributor

Choose a reason for hiding this comment

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

All of the models. rdar://83113368, rdar://83114538 need to be done before we can remove reference and repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yim-lee does this help: dcb79b3

Copy link
Contributor

Choose a reason for hiding this comment

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

@tomerd yes

public let identity: PackageIdentity

/// Package's location
public let location: String

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto ^. Cannot remove repository until rdar://83113368 and rdar://83114538 are 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.

@yim-lee does this help: dcb79b3

@tomerd
Copy link
Contributor Author

tomerd commented Sep 14, 2021

@swift-ci please smoke test

switch findPackageResult {
case .failure(let error):
callback(.failure(error))
case .success(let packagesCollections):
// A package identity can be associated with multiple repository URLs
let matches = packagesCollections.packages.filter { $0.reference.canonicalLocation == reference.canonicalLocation }
let matches = packagesCollections.packages.filter { $0.identity == identity }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this filtering is no longer needed because $0.identity == identity should be true for all the items in the result.

If we are confident that identity offers "enough" uniqueness, we can potentially revert some of the changes we made in #3543, but at the minimum we can remove this filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh interesting, I missed that point. we could also add the location as an argument here and continue to do the canonical check. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but in general... the idea of identity is that its unique, so if two collections offer different packages with the same identity, there is def something a bit wrong going on

Copy link
Contributor

Choose a reason for hiding this comment

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

the idea of identity is that its unique, so if two collections offer different packages with the same identity, there is def something a bit wrong going on

Right, that was the original assumption.

we could also add the location as an argument here and continue to do the canonical check. wdyt?

Yes, I think I would be more comfortable with this until we completely switch over to identity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tomerd
Copy link
Contributor Author

tomerd commented Sep 15, 2021

@swift-ci please smoke test

@tomerd tomerd added the ready Author believes the PR is ready to be merged & any feedback has been addressed label Sep 15, 2021
@tomerd tomerd merged commit 037d075 into swiftlang:main Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Author believes the PR is ready to be merged & any feedback has been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants