Skip to content

Commit

Permalink
dev: add git commit hash to debug info
Browse files Browse the repository at this point in the history
Output:
AnkiDroid Version = 2.16.3-debug (edf739d)

While I have a development build on my Android emulator, sometimes
I encounter a bug, this makes the build much more visible to help
with diagnostics
  • Loading branch information
david-allison authored and mikehardy committed Aug 27, 2023
1 parent 31d9240 commit c779ef3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions AnkiDroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit c779ef3

Please sign in to comment.