#!/bin/sh
# Be compatible here, use `` and such old stuff

VERSION=`cat RELEASE`

if ls -d .svn > /dev/null 2>&1; then
    INFO_CMD="svn info"
elif ls -d .git > /dev/null 2>&1; then
    if which git-svn > /dev/null 2>&1; then
        INFO_CMD="git-svn info"
    else
        INFO_CMD="git svn info"
    fi
else
    INFO_CMD="echo Revision: <UNKNOWN>"
fi

case $VERSION in
    svn-*)
	R=`$INFO_CMD | awk '/^Revision: / { print $2; }'` || {
	    echo Unable to get svn revision >&2
	    exit 1
	}
	VERSION="$VERSION-r$R"
	;;
esac

echo $VERSION
