summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Beattie <mike@ethernal.org>2012-10-23 19:22:52 +1300
committerMike Beattie <mike@ethernal.org>2012-10-23 19:30:43 +1300
commit37a09f1edc57924dabcf2a71794a42e37b5a354c (patch)
treeaea22a4ed75525ac7b614aae8991e35b93cc00af
parent9e60fa214ad2c48fbe8f7e5c437681aa35d249fa (diff)
altosdroid: match only the current version tag
Don't match non version tags - and always return the long format of git describe, rather than just the tag (when the tag is on the current commit). Split the commit number/hash more reliably by removing the version tag from the result first. Signed-off-by: Mike Beattie <mike@ethernal.org>
-rwxr-xr-xaltosdroid/buildinfo.sh32
1 files changed, 19 insertions, 13 deletions
diff --git a/altosdroid/buildinfo.sh b/altosdroid/buildinfo.sh
index f620c4a0..781b251b 100755
--- a/altosdroid/buildinfo.sh
+++ b/altosdroid/buildinfo.sh
@@ -1,24 +1,30 @@
#!/bin/sh
#
+# Author: Mike Beattie <mike@ethernal.org>
+#
+# Script to parse result from git describe, and push values into
+# BuildInfo.java for use within altosdroid (to display the current
+# version and build information, primarily).
+#
-describe=$(git describe --always 2>/dev/null || echo '')
-if [ -n "$describe" ]; then
- version=$(echo $describe | cut -d- -f1)
- commitnum=$(echo $describe | cut -d- -f2)
- commithash=$(echo $describe | cut -d- -f3)
-else
- . ../src/Version
- version=$VERSION
- commitnum=''
- commithash=''
-fi
+infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
+outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
+. ../src/Version
+version=$VERSION
+commitnum=''
+commithash=''
builddate=$(date "+%Y-%m-%d")
buildtime=$(date "+%H:%M")
-infile=src/org/altusmetrum/AltosDroid/BuildInfo.java.in
-outfile=src/org/altusmetrum/AltosDroid/BuildInfo.java
+describe=$(git describe --match "$version" --long --always 2>/dev/null || echo '')
+if [ -n "$describe" ]; then
+ commitdetails=$(echo $describe | sed -e "s/^$version-//")
+ commitnum=$(echo $commitdetails | cut -d- -f1)
+ commithash=$(echo $commitdetails | cut -d- -f2)
+fi
+
echo "Version $describe, built on $builddate, $buildtime"