Skip to content

Commit 01ccc83

Browse files
committed
more: Add buildinfo field for last git commit message, by @gsantner
1 parent ff7b135 commit 01ccc83

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ android {
3636
buildConfigField "String[]", "DETECTED_ANDROID_LOCALES", "${findUsedAndroidLocales()}"
3737
buildConfigField "String", "BUILD_DATE", "\"${getBuildDate()}\""
3838
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""
39+
buildConfigField "String", "GITMSG", "\"${getGitLastCommitMessage()}\""
3940
setProperty("archivesBaseName", applicationId + "-v" + versionCode + "-" + versionName)
4041
}
4142

app/src/main/java/net/gsantner/markor/activity/MoreInfoFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public synchronized void doUpdatePreferences() {
169169
summary += (tmp = _cu.bcstr("BUILD_DATE", "")).isEmpty() ? "" : ("\n<b>Build date:</b> " + tmp);
170170
summary += (tmp = _cu.getAppInstallationSource()).isEmpty() ? "" : ("\n<b>ISource:</b> " + tmp);
171171
summary += (tmp = _cu.bcstr("GITHASH", "")).isEmpty() ? "" : ("\n<b>VCS Hash:</b> " + tmp);
172+
summary += (tmp = _cu.bcstr("GITMSG", "")).isEmpty() ? "" : ("\n<b>VCS Msg:</b> " + tmp);
172173
pref.setSummary(_cu.htmlToSpanned(summary.trim().replace("\n", "<br/>")));
173174
}
174175

build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ ext.getGitHash = { ->
110110
}
111111
}
112112

113+
ext.getGitLastCommitMessage = { ->
114+
try {
115+
def stdout = new ByteArrayOutputStream()
116+
exec {
117+
commandLine 'git', 'log', '--oneline', '-1', '--format="%s"'
118+
standardOutput = stdout
119+
}
120+
return stdout.toString().replace("\"", "").replace("\\", "").trim()
121+
} catch (Exception ignored) {
122+
return 'unknown'
123+
}
124+
}
125+
113126
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
114127
// Returns the build date in a RFC3339 compatible format. TZ is always converted to UTC
115128
static String getBuildDate() {

0 commit comments

Comments
 (0)