Skip to content

Commit f364483

Browse files
authored
Correctly handle patch versions containing dots #2599 (#2600)
1 parent 4110600 commit f364483

File tree

1 file changed

+7
-5
lines changed
  • utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils

1 file changed

+7
-5
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/Version.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package org.utbot.intellij.plugin.ui.utils
55
* Contains three standard components: major, minor and patch.
66
*
77
* Major and minor components are always numbers, while patch
8-
* may contain a number with some postfix like -RELEASE.
8+
* may contain a number with some optional postfix like `-RELEASE` or `.RELEASE`.
99
*
1010
* Sometimes patch is empty, e.g. for TestNg 7.5 version.
1111
*
@@ -18,9 +18,10 @@ data class Version(
1818
val plainText: String? = null,
1919
) {
2020
fun isCompatibleWith(another: Version): Boolean {
21-
//Non-numeric versions can't be compared to each other, so we cannot be sure that current is compatible
21+
// Non-numeric versions can't be compared to each other,
22+
// so we cannot be sure that current is compatible unless it's the exact match
2223
if (!hasNumericOrEmptyPatch() || !hasNumericOrEmptyPatch()) {
23-
return false
24+
return plainText == another.plainText
2425
}
2526

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

4040
// Components must be: major, minor and (optional) patch
41-
if (versionComponents.size < 2 || versionComponents.size > 3) {
41+
val versionComponents = versionText.split('.', limit = 3)
42+
43+
if (versionComponents.size < 2) {
4244
return null
4345
}
4446

0 commit comments

Comments
 (0)