From 4d79ec5fff0644636ea44f51d52c431f2de6f57c Mon Sep 17 00:00:00 2001 From: Hasinjato Date: Wed, 12 Aug 2026 12:14:23 +0300 Subject: [PATCH] Create tag v1.0.0 and place in AboutPage on version --- composeApp/build.gradle.kts | 46 ++++++++++++++++--- .../mg/dot/feufaro/AndroidFileRepository.kt | 7 ++- .../kotlin/mg/dot/feufaro/ui/AboutScreen.kt | 2 +- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 75bad18..699d22c 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -1,8 +1,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import java.util.Properties +import java.io.ByteArrayOutputStream plugins { alias(libs.plugins.kotlinMultiplatform) @@ -13,7 +12,9 @@ plugins { alias(libs.plugins.kotlinSerialization) } -val appVersion = "1.0.0" +val gitVersionCode = getGitCommitCount() +val gitVersionName = getGVN() +val desktopVersionName = getCleanDesktopVersion(gitVersionName) kotlin { /*linuxX64 { binaries { @@ -114,8 +115,8 @@ android { applicationId = "mg.dot.feufaro" minSdk = libs.versions.android.minSdk.get().toInt() targetSdk = libs.versions.android.targetSdk.get().toInt() - versionCode = 1 - versionName = appVersion + versionCode = gitVersionCode + versionName = gitVersionName } packaging { resources { @@ -144,8 +145,8 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Exe, TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "Feufaro" - packageVersion = appVersion - jvmArgs("-Dapp.version=$appVersion") + packageVersion = desktopVersionName + jvmArgs("-Dapp.version=$gitVersionName") modules("java.base", "java.desktop", "jdk.unsupported", "java.naming") windows { @@ -231,3 +232,34 @@ tasks.register("exportLibs") { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } + +fun getGitCommitCount(): Int { + return try { + val execResult = providers.exec { + commandLine("git", "rev-list", "--count", "HEAD") + } + val countStr = execResult.standardOutput.asText.get().trim() + val count = countStr.toIntOrNull() ?: 1 + if (count > 0) count else 1 + } catch (e: Exception) { + 1 + } +} + +fun getGVN(): String { + val execResult = providers.exec { + commandLine("git", "describe", "--tags", "--always", "--abbrev=0") + } + val rawVersion = execResult.standardOutput.asText.get().trim() + + return if (rawVersion.isNotEmpty()) { + rawVersion + } else { + "v1.0.0" + } +} + +fun getCleanDesktopVersion(versionName: String): String { + val regex = Regex("""^\d+(\.\d+)*""") + return regex.find(versionName)?.value ?: "1.0.0" +} \ No newline at end of file diff --git a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidFileRepository.kt b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidFileRepository.kt index dc6abee..0efd794 100644 --- a/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidFileRepository.kt +++ b/composeApp/src/androidMain/kotlin/mg/dot/feufaro/AndroidFileRepository.kt @@ -125,9 +125,14 @@ class AndroidFileRepository(private val context: Context) : FileRepository { } else { val shortDisplayPath = longPathToShort(displayPath) + val message = if (shortDisplayPath.endsWith(".json", ignoreCase = true)) { + "Playlist mise à jour" + } else { + "Sauvegarde réussie dans : $shortDisplayPath" + } Toast.makeText( context.applicationContext, - "Sauvegarde réussie dans : $shortDisplayPath", + message, Toast.LENGTH_LONG ).show() } diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/AboutScreen.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/AboutScreen.kt index b7023e9..03db126 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/AboutScreen.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/AboutScreen.kt @@ -98,7 +98,7 @@ fun AboutDialog(onDismiss: () -> Unit) { modifier = Modifier.padding(top = 4.dp, bottom = 16.dp) ) { Text( - text = "Version $appVersion", + text = appVersion, modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSecondaryContainer