Skip to content

Commit

Permalink
Make sure 1.10.0 is higher than 1.10.0-SNAPSHOT in version check #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsz committed Nov 17, 2022
1 parent 2e3b539 commit fd0f64b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/org/jetbrains/intellij/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Version(
.or { patch - other.patch }
.or {
when {
version.contains('-') -> -1
other.version.contains('-') -> 1
else -> 0
version.contains('-') && !other.version.contains('-') -> -1
!version.contains('-') && other.version.contains('-') -> 1
else -> version.compareTo(other.version, ignoreCase = true)
}
}
.or { version.compareTo(other.version, ignoreCase = true) }
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/org/jetbrains/intellij/VersionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ class VersionTest {
assertTrue(Version.parse("2021.1.2") > Version.parse("2020"))
assertEquals(Version.parse("2021.1.0-snapshot"), Version.parse("2021.1.0-SNAPSHOT"))
assertTrue(Version.parse("2021.1.2-SNAPSHOT.2") > Version.parse("2021.1.2-SNAPSHOT.1"))
assertTrue(Version.parse("2021.1.2") > Version.parse("2021.1.2-SNAPSHOT.1"))
}
}

0 comments on commit fd0f64b

Please sign in to comment.