scripts: Update git-version-gen to be more useful.

This commit is contained in:
Solomon Peachy 2013-08-04 08:55:54 -04:00
parent b56572dfa2
commit a54523cac7
1 changed files with 16 additions and 6 deletions

View File

@ -11,10 +11,16 @@ then
VN=$(cat version)
elif test -d .git
then
VN=$(git describe 2>/dev/null) &&
git update-index -q --refresh
# test -z "$(git diff-index --name-only HEAD --)" ||
# VN="$VN-dirty"
VN=$(git describe 2>/dev/null) && git update-index -q --refresh
HEAD=$(git rev-parse --verify --short HEAD 2>/dev/null)
if [ -n "$VN" ] ; then
VN="$VN-$HEAD"
else
VN="none-$HEAD"
fi
test -z "$(git diff-index --name-only HEAD --)" || VN="$VN-dirty"
else
VN="$DEF_VER"
fi
@ -30,9 +36,13 @@ then
else
VC=unset
fi
test "\"$VN\"" = "$VC" -a "\"-$APP\"" = "$VM" || {
if [ -n "$APP" ] ; then
APP="-$APP"
fi
test "\"$VN\"" = "$VC" -a "\"$APP\"" = "$VM" || {
echo "#define SYSTEM_VERSION \"$VN\"" >$GVF
echo "#define SYSTEM_APP \"-$APP\"" >>$GVF
echo "#define SYSTEM_APP \"$APP\"" >>$GVF
}