aboutsummaryrefslogtreecommitdiffhomepage
path: root/build_tools
diff options
context:
space:
mode:
authorGravatar David Adam (zanchey) <zanchey@ucc.gu.uwa.edu.au>2013-06-24 18:09:29 +0800
committerGravatar David Adam (zanchey) <zanchey@ucc.gu.uwa.edu.au>2013-08-11 23:13:38 +0800
commit05563ab11ee30fbf698c0bbfcb9f98e2533a0a1d (patch)
tree68835d48d75e7dc84f3d6590912c1270a2bcf642 /build_tools
parent625a1cb0b57112c4ce84c665a16c0fee364c49f8 (diff)
add git_version_gen: generate a version number from the git tree
Originally from the git sources (GIT-VERSION-GEN) (C) Junio C Hamano <junkio@cox.net> Reused under GPL v2.0
Diffstat (limited to 'build_tools')
-rwxr-xr-xbuild_tools/git_version_gen.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/build_tools/git_version_gen.sh b/build_tools/git_version_gen.sh
new file mode 100755
index 00000000..5a54eb3b
--- /dev/null
+++ b/build_tools/git_version_gen.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Originally from the git sources (GIT-VERSION-GEN)
+# Presumably (C) Junio C Hamano <junkio@cox.net>
+# Reused under GPL v2.0
+# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
+
+FBVF=FISH-BUILD-VERSION-FILE
+DEF_VER=2.0.GIT
+
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+if test -f version
+then
+ VN=$(cat version) || VN="$DEF_VER"
+elif test -d .git -o -f .git && which git >/dev/null
+then
+ VN=$(git describe --tags --dirty 2>/dev/null)
+else
+ VN="$DEF_VER"
+fi
+
+if test -r $FBVF
+then
+ VC=$(sed -e 's/^FISH_BUILD_VERSION = //' <$FBVF)
+else
+ VC=unset
+fi
+test "$VN" = "$VC" || {
+ echo >&2 "FISH_BUILD_VERSION = $VN"
+ echo "FISH_BUILD_VERSION = $VN" >$FBVF
+}