diff --git a/AnkiDroid/build.gradle b/AnkiDroid/build.gradle index 49fb2c18430f..ea1e4d402cd6 100644 --- a/AnkiDroid/build.gradle +++ b/AnkiDroid/build.gradle @@ -25,6 +25,14 @@ idea { } def homePath = System.properties['user.home'] +/** + * @return the current git hash + * @example edf739d95bad7b370a6ed4398d46723f8219b3cd + */ +static def gitCommitHash() { + "git rev-parse HEAD".execute().text.trim() +} + android { namespace "com.ichi2.anki" @@ -43,6 +51,7 @@ android { buildConfigField "String", "BACKEND_VERSION", "\"$ankidroid_backend_version\"" buildConfigField "Boolean", "ENABLE_LEAK_CANARY", "false" buildConfigField "Boolean", "ALLOW_UNSAFE_MIGRATION", "false" + buildConfigField "String", "GIT_COMMIT_HASH", "\"${gitCommitHash()}\"" resValue "string", "app_name", "AnkiDroid" // The version number is of the form: diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt index 2c0b4a944046..f862c40225c1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/servicelayer/DebugInfoService.kt @@ -42,7 +42,7 @@ object DebugInfoService { val webviewUserAgent = getWebviewUserAgent(info) val newSchema = !BackendFactory.defaultLegacySchema return """ - AnkiDroid Version = $pkgVersionName + AnkiDroid Version = $pkgVersionName (${BuildConfig.GIT_COMMIT_HASH}) Android Version = ${Build.VERSION.RELEASE}