-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix discrepancies with usage of package display name/package identity in swift package edit
command
#7941
Conversation
swift package edit was reliant on the user-passed packageName argument to be able to both find the dependency (which needs the identity) as well as to match the manifest display name. Default to treating the user-passed argument as a package identity, and fix the comparisons made to the manifest by instead assuring that the canonical locations for the manifest and the dependency match. The display name was intended to be deprecated.
Keep packageName in the Edit command so it does not introduce a breaking change; add validate method to propagate the value of the packageName to packageIdentity.
Update the Unedit command as well.
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.
Looking good, one last small question
@swift-ci please test |
@swift-ci please test macOS platform |
FYI I'll be writing a forum post about this change before I merge. |
@@ -32,16 +32,16 @@ extension SwiftPackageCommand { | |||
@Option(help: "Create or use the checkout at this path") | |||
var path: AbsolutePath? | |||
|
|||
@Argument(help: "The name of the package to edit") | |||
var packageName: String | |||
@Argument(help: "The identity of the package to edit.") |
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: none of the other help strings have a period
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.
Good catch, thank you!
@@ -61,15 +61,15 @@ extension SwiftPackageCommand { | |||
help: "Unedit the package even if it has uncommitted and unpushed changes") | |||
var shouldForceRemove: Bool = false | |||
|
|||
@Argument(help: "The name of the package to unedit") | |||
var packageName: String | |||
@Argument(help: "The identity of the package to unedit.") |
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: same
@swift-ci please test |
@swift-ci please test windows platform |
Fixes #7931
swift package edit
was reliant on the user-passedpackageName
argument to be able to both find the dependency (which needs the identity) as well as to match the manifest display name.Default to treating the user-passed argument as a package identity, and fix the comparisons made to the manifest by instead assuring that the canonical locations for the manifest and the dependency match. The display name was intended to be deprecated.
Motivation:
The vscode-swift extension made use of of the package identities when listing dependencies in its UI. When a user would execute a
Use Local Version
on one of these dependencies, it would callswift package edit <package-name>
under the hood, using the identity for the package-name argument. However, this would fail as theedit
command would also treat the package name argument as the package's manifestdisplayName
, which is not guaranteed to match the identity.Modifications:
Treat the user-passed argument as the package identity, and deprecate the usage of
displayName
in theedit
command. Fix any necessary test cases to follow suite with this change.Result:
The
edit
command should now be using the package identity, and there should no longer be any discrepancies.