Skip to content

Correctly handle patch versions containing dots #2600

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

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package org.utbot.intellij.plugin.ui.utils
* Contains three standard components: major, minor and patch.
*
* Major and minor components are always numbers, while patch
* may contain a number with some postfix like -RELEASE.
* may contain a number with some optional postfix like `-RELEASE` or `.RELEASE`.
*
* Sometimes patch is empty, e.g. for TestNg 7.5 version.
*
Expand All @@ -18,9 +18,10 @@ data class Version(
val plainText: String? = null,
) {
fun isCompatibleWith(another: Version): Boolean {
//Non-numeric versions can't be compared to each other, so we cannot be sure that current is compatible
// Non-numeric versions can't be compared to each other,
// so we cannot be sure that current is compatible unless it's the exact match
if (!hasNumericOrEmptyPatch() || !hasNumericOrEmptyPatch()) {
return false
return plainText == another.plainText
}

return major > another.major ||
Expand All @@ -35,10 +36,11 @@ data class Version(
fun String.parseVersion(): Version? {
val lastSemicolon = lastIndexOf(':')
val versionText = substring(lastSemicolon + 1)
val versionComponents = versionText.split('.')

// Components must be: major, minor and (optional) patch
if (versionComponents.size < 2 || versionComponents.size > 3) {
val versionComponents = versionText.split('.', limit = 3)

if (versionComponents.size < 2) {
return null
}

Expand Down