Skip to content

Commit

Permalink
refactor(go): Move normalizeModuleVersion() to GoMod.kt
Browse files Browse the repository at this point in the history
As of the removal of `GoDep` the function is called only from
`GoMod.kt`. So, move it there.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Apr 5, 2024
1 parent 3ce77c7 commit 5818de3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
8 changes: 7 additions & 1 deletion plugins/package-managers/go/src/main/kotlin/GoMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.orEmpty
import org.ossreviewtoolkit.plugins.packagemanagers.go.utils.Graph
import org.ossreviewtoolkit.plugins.packagemanagers.go.utils.normalizeModuleVersion
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.splitOnWhitespace
import org.ossreviewtoolkit.utils.common.stashDirectories
Expand Down Expand Up @@ -489,3 +488,10 @@ internal fun escapeModuleVersion(version: String): String {
}

private val upperCaseCharRegex = Regex("[A-Z]")

/**
* Return the given [moduleVersion] normalized to a Semver compliant version. The `v` prefix gets stripped and
* also any suffix starting with '+', because build metadata is not involved in version comparison according to
* https://go.dev/ref/mod#incompatible-versions.
*/
private fun normalizeModuleVersion(moduleVersion: String): String = moduleVersion.removePrefix("v").substringBefore("+")
27 changes: 0 additions & 27 deletions plugins/package-managers/go/src/main/kotlin/utils/GoSupport.kt

This file was deleted.

0 comments on commit 5818de3

Please sign in to comment.