CORD-745 - update version label for docker containers

Change-Id: Ie51f3523271179a24764c36f6c81599d34483f5f
diff --git a/build.gradle b/build.gradle
index d5dac1f..d85ad1a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -105,13 +105,34 @@
     return hashStdOut.toString().trim()
 }
 
-def getBranchName = { ->
-    def branchStdOut = new ByteArrayOutputStream()
+def isModified = { ->
+    def statusOut = new ByteArrayOutputStream()
+    def branchesOut = new ByteArrayOutputStream()
     exec {
-        commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
-        standardOutput = branchStdOut
+        commandLine "bash", "-c", "repo --color=never --no-pager status . | tail -n +2 | wc -l"
+        standardOutput = statusOut
     }
-    return branchStdOut.toString().trim()
+    exec {
+        commandLine "bash", "-c", "repo --color=never --no-pager branches | wc -l"
+        standardOutput = branchesOut
+    }
+    def statusVal = statusOut.toString().trim()
+    def branchesVal = branchesOut.toString().trim()
+
+    return statusVal != "0" || branchesVal != "0"
+}
+
+def getBranchName = { ->
+    def stdout = new ByteArrayOutputStream()
+    exec {
+        commandLine "bash", "-c", "repo --color=never --no-pager info -l -o | grep 'Manifest branch:' | awk '{print \$NF}'"
+        standardOutput = stdout
+    }
+    def val = stdout.toString().trim()
+    if ( isModified() != "0" ) {
+        val += '[modified]'
+    }
+    return val
 }
 
 task buildSwitchqImage(type: Exec) {