-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add nested PackgeIdentity.Scope
and PackageIdentity.Name
types
#3658
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
This comment has been minimized.
This comment has been minimized.
cc @yim-lee for another set of eyes on the validation logic |
I think the rough idea would be:
I think this implies that prior to #3640 we have to implement a new, explicit override mechanism. We'll also have to figure out a good way to transition folks to explicit overrides. Without the presence of an override, a dependency with legacy identity is always considered to be different from one with scope/name based identity. Implementation-wise, we could also think of all package with legacy identity to be part of a single scope (that's somehow not valid as an actual scope to avoid collisions) and the last path component becoming the name. |
public struct Scope: LosslessStringConvertible, Hashable, Equatable, Comparable, ExpressibleByStringLiteral { | ||
public let description: String | ||
|
||
public init(validating description: String) throws { |
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.
Can we use regex patterns to do the validation?
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.
We could, but I can think of a few drawbacks to that approach:
- Less precise errors (a regex match is all or nothing, so you can't know why it's invalid)
- Somewhat worse performance (a regex engine is slower than Swift string APIs)
- More coupling (it creates a dependency on a regex engine, which could complicate cross-platform deployment)
On the plus side, a regex is a more obvious representation than string manipulation code. But with comprehensive testing, that's probably less of a concern.
@neonichu That sounds about right to me. Implementation-wise, one approach to help us navigate the transition would be to change public enum PackageIdentity: Hashable {
case synthesized(name: String)
case local(path: AbsolutePath)
case repository(url: String)
case registry(scope: Scope, name: Name)
/* ... */
} |
This comment has been minimized.
This comment has been minimized.
@swift-ci please smoke test |
Adds package identity scope and name types as defined by SE-0292 (according to updated naming rules proposed by #3624).
Motivation:
Implement SE-0292.
Modifications:
PackgeIdentity.Scope
type and related testsPackageIdentity.Name
type and related testsResult:
The types added by this PR are tested, but not otherwise used by other APIs, so this change has no immediate effect.