summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/git-version21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/git-version b/scripts/git-version
new file mode 100755
index 0000000..850c19b
--- /dev/null
+++ b/scripts/git-version
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+version='v0.0.1'
+
+if test -d .git
+then
+ gv=`git describe`
+ if [[ "$?" == "0" ]]
+ then
+ if [[ "$(echo "${gv}" | cut -d'-' -f1)" != "$version" ]]
+ then
+ echo "$0 has mismatched version" >&2
+ echo "${gv}-ERROR"
+ exit 1
+ fi
+
+ version="$(echo ${gv} | cut -c2-)"
+ fi
+fi
+
+echo "${version}"