Commit 75f8983c authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Include the current commit hash in the about dialog, log and mail template

Implements #201
parent f681086e
......@@ -29,6 +29,8 @@ android {
versionName "1.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "COMMIT_HASH", '"' + getGitCommitHash() + '"')
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
......@@ -148,3 +150,12 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
def getGitCommitHash() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
\ No newline at end of file
......@@ -108,7 +108,7 @@ fun Context.log(e: Throwable, extras: Map<String, String>? = null) {
if (errorFile.createNewFile()) {
val writer = BufferedWriter(FileWriter(errorFile, false))
writer.write("App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})\n")
writer.write("App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE}, Commit: ${BuildConfig.COMMIT_HASH})\n")
writer.write("Android SDK version: ${Build.VERSION.SDK_INT} (${Build.VERSION.RELEASE} - ${Build.VERSION.CODENAME})\n")
writer.write("Device: ${Build.MODEL} from ${Build.MANUFACTURER} (Device: ${Build.DEVICE}, Product: ${Build.PRODUCT})\n")
writer.write("------------------------------\n")
......
......@@ -66,7 +66,7 @@ class AboutFragment : Fragment() {
getString(R.string.about_contact_developer),
getString(R.string.app_name),
getString(R.string.support_contact_mail),
"\n\n\n\n\n\nSystem:\nApp version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})\n" +
"\n\n\n\n\n\nSystem:\nApp version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE};${BuildConfig.COMMIT_HASH})\n" +
"Android: ${Build.VERSION.SDK_INT} (${Build.VERSION.RELEASE} - ${Build.VERSION.CODENAME})"
)
}
......@@ -89,7 +89,7 @@ class AboutFragment : Fragment() {
getString(R.string.menu_about),
getString(
R.string.about_app,
BuildConfig.VERSION_NAME + if (BuildConfig.DEBUG) " DEBUG" else "",
BuildConfig.VERSION_NAME + (if (BuildConfig.DEBUG) " DEBUG" else "") + " (Commit ${BuildConfig.COMMIT_HASH})",
BuildConfig.VERSION_CODE,
AppDatabase.currentVersion,
if (context!!.getPreferences().crashreportingType == Crashreporting.FULL) context!!.getPreferences().crashReportingUUID else "---"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment