mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 07:29:14 +01:00
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.
This commit is contained in:
@@ -14,6 +14,19 @@ ktlint {
|
|||||||
version.set(libs.versions.ktlint.get())
|
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 {
|
android {
|
||||||
namespace = "com.subtracks"
|
namespace = "com.subtracks"
|
||||||
compileSdk = 37
|
compileSdk = 37
|
||||||
@@ -25,6 +38,7 @@ android {
|
|||||||
targetSdk = 37
|
targetSdk = 37
|
||||||
versionCode = 13
|
versionCode = 13
|
||||||
versionName = "3.0.0"
|
versionName = "3.0.0"
|
||||||
|
buildConfigField("String", "COMMIT_HASH", "\"$commitHash\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
|
|||||||
@@ -388,7 +388,16 @@ fun SettingsScreen(
|
|||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.app_name)) },
|
headlineContent = { Text(stringResource(R.string.app_name)) },
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
Text(stringResource(R.string.settings_about_version, BuildConfig.VERSION_NAME))
|
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) },
|
leadingContent = { Icon(Icons.Rounded.Info, contentDescription = null) },
|
||||||
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
||||||
|
|||||||
Reference in New Issue
Block a user