Skip to content

Commit

Permalink
fix(spm): Ensure uniqueness of identifiers for projects
Browse files Browse the repository at this point in the history
Using the name of the reprository yields duplicate IDs if there
is more than one project in the repository.

Signed-off-by: Frank Viernau <[email protected]>
fviernau committed Jan 17, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent dac1854 commit 3205ec9
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
project:
id: "SPM:oss-review-toolkit:ort:<REPLACE_REVISION>"
id: "SPM:oss-review-toolkit:src/funTest/assets/projects/synthetic/spm-app/Package.resolved:<REPLACE_REVISION>"
definition_file_path: "<REPLACE_DEFINITION_FILE_PATH>"
declared_licenses: []
declared_licenses_processed: {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
project:
id: "SPM:oss-review-toolkit:ort:<REPLACE_REVISION>"
id: "SPM:oss-review-toolkit:src/funTest/assets/projects/synthetic/spm-lib/Package.swift:<REPLACE_REVISION>"
definition_file_path: "<REPLACE_DEFINITION_FILE_PATH>"
declared_licenses: []
declared_licenses_processed: {}
4 changes: 2 additions & 2 deletions plugins/package-managers/spm/src/main/kotlin/Spm.kt
Original file line number Diff line number Diff line change
@@ -141,13 +141,13 @@ class Spm(

private fun projectFromDefinitionFile(definitionFile: File): Project {
val vcsInfo = VersionControlSystem.forDirectory(definitionFile.parentFile)?.getInfo().orEmpty()
val (author, project) = parseAuthorAndProjectFromRepo(repositoryURL = vcsInfo.url)
val (author, _) = parseAuthorAndProjectFromRepo(repositoryURL = vcsInfo.url)

val projectIdentifier = Identifier(
type = managerName,
version = vcsInfo.revision,
namespace = author.orEmpty(),
name = project ?: definitionFile.parentFile.relativeTo(analysisRoot).invariantSeparatorsPath
name = getFallbackProjectName(analysisRoot, definitionFile)
)

return Project(

0 comments on commit 3205ec9

Please sign in to comment.