-
Notifications
You must be signed in to change notification settings - Fork 339
fix(swiftpm): Use identity
as name
for Swift PM registry dependencies
#10124
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(swiftpm): Use identity
as name
for Swift PM registry dependencies
#10124
Conversation
Thanks a lot for the contribution @liedQM! Please have a look at the failing commit linter: You should hard-wrap commit message body lines at column 75. |
@@ -244,7 +244,12 @@ private fun PinV2.toId(): Identifier = | |||
Identifier( | |||
type = PACKAGE_TYPE, | |||
namespace = "", | |||
name = getCanonicalName(location), | |||
// For SPM registry dependencies the `location` field is blank -> Use `identity` 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.
Nit: Please make this a sentence as "written in a book" (e.g. with a dot at the end):
// For SPM registry dependencies the `location` field is blank, so use the `identity` field 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.
Shall we move this comment to the location
property?
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.
Thanks for the sentence suggestion, I've applied it.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10124 +/- ##
=========================================
Coverage 69.60% 69.60%
Complexity 1454 1454
=========================================
Files 270 270
Lines 9668 9668
Branches 1028 1028
=========================================
Hits 6729 6729
Misses 2487 2487
Partials 452 452
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
...est/assets/projects/synthetic/only-lockfile-v3-with-SPM-registry-dependency/Package.resolved
Show resolved
Hide resolved
@@ -244,7 +244,12 @@ private fun PinV2.toId(): Identifier = | |||
Identifier( | |||
type = PACKAGE_TYPE, | |||
namespace = "", | |||
name = getCanonicalName(location), | |||
// For SPM registry dependencies the `location` field is blank -> Use `identity` 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.
Shall we move this comment to the location
property?
Thanks for the fast feedback. Just a short note: You refer to https://robertcooper.me/post/git-commit-messages in your Contribution Guideline which limits the commit messages to 80 characters (which I've followed). It would be nice to add a note in your guidelines regarding the smaller character count :) |
Thanks for letting us now, here's the proposed addition to the docs. |
d72561e
to
37c2438
Compare
commit-msg: Should say |
identifier
as name
for Swift PM registry dependencies to identifier
as name
for Swift PM registry dependencies
Thanks it seems I've mixed the terms up. Will fix it. |
identifier
as name
for Swift PM registry dependenciesidentity
as name
for Swift PM registry dependencies
- id: "Swift::alamofire.alamofire:5.4.4" | ||
packages: | ||
- id: "Swift::alamofire.alamofire:5.4.4" | ||
purl: "pkg:swift/[email protected]" |
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.
question: What do you guys think about the purl
? Is the current logic appropriate which sets it, as we're dealing with private registries, could this be ambigous?
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.
could this be ambigous?
Theoretically it would be. If we can be sure the registry to be a non-default one, it's probably a good idea to add the repository_url
qualifier to the purl.
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.
could this be ambigous?
Theoretically it would be. If we can be sure the registry to be a non-default one, it's probably a good idea to add the
repository_url
qualifier to the purl.
We don't get any information regarding the used registry from the Package.resolved
or Package.swift
since they are defined outside the project using the swift package-registry set
command for a specific scope, e.g. alarmofire
(the one before the .
) in the test example.
Note: The Package.swift
entry for the test example would be:
.package(
id: "alamofire.alamofire",
from: 5.4.4
)
Currently only the `location` field is used to derive the `name` of a Swift PM dependency. For dependencies fetched over a Package Registry Service (Swift PM registry) the `location` field is empty which leads to incomplete and invalid results. For those dependencies the `identity` needs to be used instead. Signed-off-by: Marco Lied <[email protected]>
37c2438
to
f3980be
Compare
Do you need anything from me for the PR to be merged? The missing registry support blocks us to switch to ORT since a lot of dependencies are missed in the scan. |
@fviernau could you please do another review? |
yes, I'm ok to merge this as a "partial" solution, even though @liedQM just out of curiosity: Would you know whether SwiftPM has a command to retrieve metadata for such package from the remote registry. E.g. the name, description and so forth? |
@fviernau currently I'm not aware of any way despite reading it out of the a global settings file. I've been looking into the available swift pm commands and haven't found any to read the current scope configuration yet. |
Thanks for merging my PR :) |
Yes, we do. |
Currently only the
location
field is used to derive thename
of a Swift PM dependency. For dependencies fetched over a Package Registry Service (Swift PM registry) thelocation
field is empty which leads to incomplete and invalid results. For those dependencies theidentity
needs to be used instead.Technical notes:
broken:


fixed:
Note: Like seen, the scan also stops resolving the broken SPM registries further which results in much shorter scan results.
expected:
but was: