-
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 resolve failing when package from registry is referenced by name #8166
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Max Desiatov <[email protected]>
// makes sure we use the updated package name for target based dependencies | ||
let modifiedPackageName = targetDependencyPackageNameTransformations[packageName] { |
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: formatting seems off by one whitespace here
// makes sure we use the updated package name for target based dependencies | |
let modifiedPackageName = targetDependencyPackageNameTransformations[packageName] { | |
// makes sure we use the updated package name for target based dependencies | |
let modifiedPackageName = targetDependencyPackageNameTransformations[packageName] { |
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.
This is indented with Xcode's Editor > Structure > Re-indent
. Are you sure you'd prefer it to be re-indented as you suggested instead?
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.
Per CONTRIBUTING.md
we prefer SwiftFormat instead of Xcode or swift-format in this repository. It's also very surprising that Xcode suggests 3-spaces formatting even if for a few lines. Regardless, I don't insist applying SwiftFormat here unless you can easily avoid mass reformatting the whole file to keep the diff of this PR manageable.
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.
LGTM modulo some formatting nits. Thanks!
@swift-ci test |
Thanks @MaxDesiatov for the speedy review (I don't think I've ever had my PR reviewed faster in an open source repository 😅). I applied the |
@swift-ci test |
Hey @MaxDesiatov 👋 Are we waiting for some additional reviews or is there anything else that needs to be done before this PR can be merged? |
@swift-ci test windows |
This can't be merged currently due to https://forums.swift.org/t/holiday-schedule-2024/75954 |
Got it, thanks for the quick response. Happy holidays 🎄 |
Fix resolve failing when package from registry is referenced by name
Motivation:
When running
swift package --replace-scm-with-registry --default-registry-url {our-registry-url} resolve
, the command fails when depending on packages that reference their transitive dependencies by name.I created a demo where you can reproduce the issue by running
swift package --replace-scm-with-registry --default-registry-url {our-registry-url} resolve
. You should see the following error:The issue boils down to:
The issue is that when swizzling the package product names to their identity counterparts, only dependencies referenced via
.product(...)
are swizzled. Indeed, when we change theXcbeautifyLib
's dependencies to:the resolution succeeds.
Modifications:
To fix the above issue, we swizzle also dependencies referenced by name iff the product name is the same as the package name the root depends on. This aligns with how
byName
is treated in other parts of the codebase, such as here.Result:
swift package --replace-scm-with-registry --default-registry-url {our-registry-url} resolve
succeeds when run in the repro sample.