From 7bbc29a1d696ce41adb9ae87f991f2596baa3adf Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Fri, 9 Oct 2026 18:00:29 +0000 Subject: [PATCH] feat: show the build's commit hash under About A short, faded commit hash next to the version in Settings > About, so a bug report can name the exact build. Baked into BuildConfig at build time from `git rev-parse HEAD` (fixed 7 chars, so the same commit always yields the same value and the APK stays reproducible); empty, and hidden, on a build with no git metadata such as a source tarball. --- app/build.gradle.kts | 14 ++++++++++++++ .../com/subtracks/ui/settings/SettingsScreen.kt | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index eb2e42ac..90938dc6 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,6 +14,19 @@ ktlint { version.set(libs.versions.ktlint.get()) } +val commitHash: String = + runCatching { + providers + .exec { + commandLine("git", "rev-parse", "HEAD") + workingDir = rootProject.layout.projectDirectory.asFile + isIgnoreExitValue = true + }.standardOutput.asText + .get() + .trim() + .take(7) + }.getOrDefault("") + android { namespace = "com.subtracks" compileSdk = 37 @@ -25,6 +38,7 @@ android { targetSdk = 37 versionCode = 13 versionName = "3.0.0" + buildConfigField("String", "COMMIT_HASH", "\"$commitHash\"") } buildFeatures { diff --git a/app/src/main/kotlin/com/subtracks/ui/settings/SettingsScreen.kt b/app/src/main/kotlin/com/subtracks/ui/settings/SettingsScreen.kt index de5180c5..607a0f6e 100644 --- a/app/src/main/kotlin/com/subtracks/ui/settings/SettingsScreen.kt +++ b/app/src/main/kotlin/com/subtracks/ui/settings/SettingsScreen.kt @@ -388,7 +388,16 @@ fun SettingsScreen( ListItem( headlineContent = { Text(stringResource(R.string.app_name)) }, supportingContent = { - Text(stringResource(R.string.settings_about_version, BuildConfig.VERSION_NAME)) + Row(verticalAlignment = Alignment.CenterVertically) { + Text(stringResource(R.string.settings_about_version, BuildConfig.VERSION_NAME)) + if (BuildConfig.COMMIT_HASH.isNotEmpty()) { + Spacer(Modifier.width(8.dp)) + Text( + BuildConfig.COMMIT_HASH, + color = MaterialTheme.colorScheme.outline, + ) + } + } }, leadingContent = { Icon(Icons.Rounded.Info, contentDescription = null) }, colors = ListItemDefaults.colors(containerColor = Color.Transparent),