Skip to content
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

Merged
merged 6 commits into from
Sep 19, 2024

Conversation

bripeticca
Copy link
Contributor

@bripeticca bripeticca commented Sep 5, 2024

Fixes #7931

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.

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 call swift package edit <package-name> under the hood, using the identity for the package-name argument. However, this would fail as the edit command would also treat the package name argument as the package's manifest displayName, 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 the edit command. Fix any necessary test cases to follow suite with this change.

Result:

Theedit command should now be using the package identity, and there should no longer be any discrepancies.

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.
Copy link
Contributor

@plemarquand plemarquand left a 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

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@plemarquand
Copy link
Contributor

@swift-ci please test macOS platform

@bripeticca
Copy link
Contributor Author

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

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

Copy link
Contributor Author

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

Choose a reason for hiding this comment

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

Nit: same

@bripeticca
Copy link
Contributor Author

@swift-ci please test

@bripeticca
Copy link
Contributor Author

@swift-ci please test windows platform

@bripeticca bripeticca merged commit 935980c into swiftlang:main Sep 19, 2024
5 checks passed
@bripeticca bripeticca deleted the editcase branch September 19, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Local Version -- Case Sensitivity Problems
4 participants