From 972a287b1da14c1362dad2a83de0f1e24af133a7 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 5 Dec 2025 13:08:57 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/core/configtoggle/version/Version.kt | 9 +++------ .../com/tangem/core/configtoggle/contract/VersionTest.kt | 4 ++-- .../plugin/configuration/utils/VersionNameProvider.kt | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/config-toggles/src/main/kotlin/com/tangem/core/configtoggle/version/Version.kt b/core/config-toggles/src/main/kotlin/com/tangem/core/configtoggle/version/Version.kt index 0822cec520..f19eb0ce0b 100644 --- a/core/config-toggles/src/main/kotlin/com/tangem/core/configtoggle/version/Version.kt +++ b/core/config-toggles/src/main/kotlin/com/tangem/core/configtoggle/version/Version.kt @@ -33,12 +33,9 @@ internal class Version private constructor(value: String) : Comparable 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 } diff --git a/core/config-toggles/src/test/kotlin/com/tangem/core/configtoggle/contract/VersionTest.kt b/core/config-toggles/src/test/kotlin/com/tangem/core/configtoggle/contract/VersionTest.kt index e61ace5722..f3dba4539f 100644 --- a/core/config-toggles/src/test/kotlin/com/tangem/core/configtoggle/contract/VersionTest.kt +++ b/core/config-toggles/src/test/kotlin/com/tangem/core/configtoggle/contract/VersionTest.kt @@ -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 { diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/utils/VersionNameProvider.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/utils/VersionNameProvider.kt index 905d2f12e4..01e50a8273 100644 --- a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/utils/VersionNameProvider.kt +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/utils/VersionNameProvider.kt @@ -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" } } \ No newline at end of file