From c13dda602f25460a065c30daade8a9320720e551 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 12 Nov 2024 18:29:55 +0100 Subject: [PATCH] chore(analyzer): Use permalinks in the error for duplicate projects This makes links valid / clickable to directly inspect the source. Signed-off-by: Sebastian Schuberth --- analyzer/src/main/kotlin/AnalyzerResultBuilder.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt b/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt index c50ff0a5a3508..88dcbf996524a 100644 --- a/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt +++ b/analyzer/src/main/kotlin/AnalyzerResultBuilder.kt @@ -19,6 +19,7 @@ package org.ossreviewtoolkit.analyzer +import org.ossreviewtoolkit.downloader.VcsHost import org.ossreviewtoolkit.model.AnalyzerResult import org.ossreviewtoolkit.model.DependencyGraph import org.ossreviewtoolkit.model.DependencyGraphNavigator @@ -58,12 +59,16 @@ class AnalyzerResultBuilder { val existingProject = projects.find { it.id == projectAnalyzerResult.project.id } if (existingProject != null) { - val existingDefinitionFileUrl = existingProject.let { - "${it.vcsProcessed.url}/${it.definitionFilePath}" + val existingDefinitionFileUrl = with(existingProject) { + VcsHost.fromUrl(vcsProcessed.url) + ?.toPermalink(vcsProcessed.copy(path = definitionFilePath)) + ?: "${vcsProcessed.url}/$definitionFilePath" } - val incomingDefinitionFileUrl = projectAnalyzerResult.project.let { - "${it.vcsProcessed.url}/${it.definitionFilePath}" + val incomingDefinitionFileUrl = with(projectAnalyzerResult.project) { + VcsHost.fromUrl(vcsProcessed.url) + ?.toPermalink(vcsProcessed.copy(path = definitionFilePath)) + ?: "${vcsProcessed.url}/$definitionFilePath" } val issue = createAndLogIssue(