fish-shell/build_tools/git_version_gen.sh

29 lines
729 B
Bash
Raw Normal View History

#!/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
2014-10-12 21:01:13 +08:00
DEF_VER=unknown
# 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 ! VN=$(git rev-parse --abbrev-ref HEAD)/$(git describe --always --dirty --tags 2>/dev/null); then
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
}