From 597e2a233f24b7db065336cbee89f1ce95ff1a54 Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Tue, 15 May 2018 12:47:14 +0100
Subject: [PATCH] Use git commit timestamp as build timestamp.

---
 briar-android/build.gradle | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/briar-android/build.gradle b/briar-android/build.gradle
index 7f1cdeaa5d..9e5f649bf6 100644
--- a/briar-android/build.gradle
+++ b/briar-android/build.gradle
@@ -218,16 +218,16 @@ dependencyVerification {
 	]
 }
 
-def getGitHash = { ->
+def getStdout = { command, defaultValue ->
 	def stdout = new ByteArrayOutputStream()
 	try {
 		exec {
-			commandLine 'git', 'rev-parse', '--short=7', 'HEAD'
+			commandLine = command
 			standardOutput = stdout
 		}
 		return stdout.toString().trim()
 	} catch (Exception ignored) {
-		return "No commit hash"
+		return defaultValue
 	}
 }
 
@@ -243,8 +243,10 @@ android {
 		applicationId "org.briarproject.briar.android"
 		resValue "string", "app_package", "org.briarproject.briar.android"
 		resValue "string", "app_name", "Briar"
-		buildConfigField "String", "GitHash", "\"${getGitHash()}\""
-		buildConfigField "Long", "BuildTimestamp", "${System.currentTimeMillis()}L"
+		buildConfigField "String", "GitHash",
+				"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
+		buildConfigField "Long", "BuildTimestamp",
+				"${getStdout(['git', 'log', '-n', '1', '--date=unix', '--format=%cd'], 0)}000L"
 	}
 
 	buildTypes {
-- 
GitLab