Skip to content

Commit 31a2994

Browse files
committed
fix(model): Allow the VCS information for SPDX projects to be empty
Fixes #11640. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 6b4317c commit 31a2994

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

model/src/main/kotlin/OrtResult.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ data class OrtResult(
267267
* analyzer root is the input directory of the analyzer.
268268
*/
269269
fun getFilePathRelativeToAnalyzerRoot(project: Project, path: String): String {
270+
if (project.id.type.startsWith("SPDX", ignoreCase = true) && project.vcsProcessed == VcsInfo.EMPTY) {
271+
return project.definitionFilePath
272+
}
273+
270274
val vcsPath = relativeProjectVcsPath.getValue(project.id)
271275

272276
requireNotNull(vcsPath) {

model/src/test/kotlin/OrtResultTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,23 @@ class OrtResultTest : WordSpec({
202202
ortResult.getDefinitionFilePathRelativeToAnalyzerRoot(project3) shouldBe "path/2/project3/build.gradle"
203203
}
204204

205+
"return the path to the definition file if an SPDX project has no VCS information" {
206+
val project = Project.EMPTY.copy(
207+
id = Identifier("SPDX::core-image-minimal-qemux86-64.rootfs-20260321090222"),
208+
definitionFilePath = "project/spdx.json"
209+
)
210+
val ortResult = OrtResult(
211+
Repository(
212+
vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "")
213+
),
214+
AnalyzerRun.EMPTY.copy(
215+
result = AnalyzerResult.EMPTY.copy(projects = setOf(project))
216+
)
217+
)
218+
219+
ortResult.getDefinitionFilePathRelativeToAnalyzerRoot(project) shouldBe "project/spdx.json"
220+
}
221+
205222
"fail if no repository matches" {
206223
val vcs = VcsInfo(type = VcsType.GIT, url = "https://example.com/git", revision = "")
207224
val nestedVcs1 = VcsInfo(type = VcsType.GIT, url = "https://example.com/git1", revision = "")

0 commit comments

Comments
 (0)