git-commit-vandalism/GIT-VERSION-GEN
Shawn O. Pearce 6a6459bc8f git-gui: Handle gitgui tags in version gen.
I've decided to use gitgui-0.5 as the format for tags in the
git-gui repository.  The prefix of gitgui was chosen here to
make its namespace different from the namespace used by git
itself, allowing developers to pull both tag namespaces into
the same repository.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-02-12 16:38:29 -05:00

45 lines
741 B
Bash
Executable File

#!/bin/sh
GVF=GIT-VERSION-FILE
DEF_VER=0.5.GIT
LF='
'
# First try git-describe, then see if there is a version file
# (included in release tarballs), then default
if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
gitgui-[0-9]*) : happy ;;
esac
then
VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
elif test -f version
then
VN=$(cat version) || VN="$DEF_VER"
else
VN="$DEF_VER"
fi
dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
case "$dirty" in
'')
;;
*)
VN="$VN-dirty" ;;
esac
if test -r $GVF
then
VC=$(sed -e 's/^GITGUI_VERSION = //' <$GVF)
else
VC=unset
fi
test "$VN" = "$VC" || {
echo >&2 "GITGUI_VERSION = $VN"
echo "GITGUI_VERSION = $VN" >$GVF
}