summaryrefslogtreecommitdiff
path: root/scripts/git-version
blob: 850c19b66095874feb4cf06831e8b951c9f48838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

version='v0.0.1'

if test -d .git
then
    gv=`git describe`
    if [[ "$?" == "0" ]]
    then
        if [[ "$(echo "${gv}" | cut -d'-' -f1)" != "$version" ]]
        then
    	    echo "$0 has mismatched version" >&2
            echo "${gv}-ERROR"
    	    exit 1
        fi

        version="$(echo ${gv} | cut -c2-)"
    fi
fi

echo "${version}"