2017-10-26 04:57:36 +08:00
|
|
|
#!/bin/sh
|
2013-06-24 18:09:29 +08:00
|
|
|
# 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>
|
|
|
|
|
2017-10-26 04:57:36 +08:00
|
|
|
# Obtain directory containing this script in POSIX-compatible manner
|
|
|
|
# See https://stackoverflow.com/a/43919044/17027 (public domain)
|
|
|
|
a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a#/}/"; BASEDIR=$(cd "$a"; pwd)
|
2017-10-05 12:28:55 +08:00
|
|
|
# Find the fish git directory as two levels up from this directory.
|
2017-10-26 05:43:39 +08:00
|
|
|
GIT_DIR=$(dirname "$a")
|
2017-10-05 12:28:55 +08:00
|
|
|
|
2013-06-24 18:09:29 +08:00
|
|
|
FBVF=FISH-BUILD-VERSION-FILE
|
2014-10-12 21:01:13 +08:00
|
|
|
DEF_VER=unknown
|
2013-06-24 18:09:29 +08:00
|
|
|
|
|
|
|
# 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"
|
2017-10-05 12:28:55 +08:00
|
|
|
elif ! VN=$(git -C "$GIT_DIR" describe --always --dirty 2>/dev/null); then
|
2013-06-24 18:09:29 +08:00
|
|
|
VN="$DEF_VER"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -r $FBVF
|
|
|
|
then
|
2017-10-05 12:28:55 +08:00
|
|
|
VC=$(sed -e 's/^FISH_BUILD_VERSION=//' <$FBVF)
|
2013-06-24 18:09:29 +08:00
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
2017-10-05 12:28:55 +08:00
|
|
|
echo >&2 "FISH_BUILD_VERSION=$VN"
|
|
|
|
echo "FISH_BUILD_VERSION=$VN" >$FBVF
|
2013-06-24 18:09:29 +08:00
|
|
|
}
|