summaryrefslogtreecommitdiff
path: root/get_vers.sh
blob: 2f7f2a4c479bb72691dad73f9cff64f1e44d49e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

top_srcdir=${1:-`pwd`}

if test -f ${top_srcdir}/VERSION; then
    VERSION=`cat ${top_srcdir}/VERSION`
elif test -d ${top_srcdir}/.git; then
    VERSION=`(cd $top_srcdir; git describe --abbrev=6 --dirty | sed -e 's/%7E/~/')`

    if test "$(git symbolic-ref HEAD)" != refs/heads/master; then
        REF=$(git symbolic-ref --short HEAD)
	if test "$REF" = "fatal: ref HEAD is not a symbolic ref"; then
            VERSION="$VERSION: detached head"
	else
	    VERSION="$VERSION $(echo $REF | awk -F/ '{print $NF}' | tr 'a-z-' 'A-Z ')"
        fi
    fi
fi

if test -z "$VERSION"; then
    VERSION='FROM SPACE'
fi

echo $VERSION