Updated on 2026-08-14
This commit is contained in:
parent
16b8957165
commit
972a287b1d
3 changed files with 8 additions and 11 deletions
|
|
@ -33,12 +33,9 @@ internal class Version private constructor(value: String) : Comparable<Version>
|
|||
var result = major.compareTo(other.major)
|
||||
if (result == 0) result = minor.compareTo(other.minor)
|
||||
if (result == 0) {
|
||||
when {
|
||||
fix == null && other.fix == null -> result = 0
|
||||
fix == null && other.fix != null -> result = -1
|
||||
fix != null && other.fix == null -> result = 1
|
||||
fix != null && other.fix != null -> result = fix.compareTo(other.fix)
|
||||
}
|
||||
val thisFix = fix ?: 0
|
||||
val otherFix = other.fix ?: 0
|
||||
result = thisFix.compareTo(otherFix)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ internal class VersionTest {
|
|||
|
||||
val actual = one?.compareTo(other)
|
||||
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_LESS_THAN_OTHER)
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_EQUAL_TO_OTHER)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -111,7 +111,7 @@ internal class VersionTest {
|
|||
|
||||
val actual = one?.compareTo(other)
|
||||
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_GREATER_THAN_OTHER)
|
||||
Truth.assertThat(actual).isEqualTo(ONE_IS_EQUAL_TO_OTHER)
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
|||
|
|
@ -86,9 +86,9 @@ internal class VersionNameProvider(
|
|||
|
||||
val major = matchResult.groupValues[1]
|
||||
val minor = matchResult.groupValues[2]
|
||||
val patch = matchResult.groupValues[3].ifEmpty { "0" }
|
||||
val patch = matchResult.groupValues[3]
|
||||
|
||||
return "$major.$minor.$patch"
|
||||
return if (patch.isEmpty()) "$major.$minor" else "$major.$minor.$patch"
|
||||
}
|
||||
|
||||
private fun incrementMinorVersion(version: String): String {
|
||||
|
|
@ -99,7 +99,7 @@ internal class VersionNameProvider(
|
|||
val minor = parts[1].toIntOrNull() ?: return version
|
||||
val newMinor = minor + 1
|
||||
|
||||
return "$major.$newMinor.0"
|
||||
return "$major.$newMinor"
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue