http_server: simplify use=
[rainbows.git] / GIT-VERSION-GEN
bloba501bceea8d3737f741fae1023020e146e6cf6e9
1 #!/bin/sh
3 GVF=GIT-VERSION-FILE
4 DEF_VER=v0.93.0
5 # DEF_VER=v0.93.0.GIT
7 LF='
10 # First see if there is a version file (included in release tarballs),
11 # then try git-describe, then default.
12 if test -f version
13 then
14 VN=$(cat version) || VN="$DEF_VER"
15 elif test -d .git -o -f .git &&
16 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
17 case "$VN" in
18 *$LF*) (exit 1) ;;
19 v[0-9]*)
20 git update-index -q --refresh
21 test -z "$(git diff-index --name-only HEAD --)" ||
22 VN="$VN-dirty" ;;
23 esac
24 then
25 VN=$(echo "$VN" | sed -e 's/-/./g');
26 else
27 VN="$DEF_VER"
30 VN=$(expr "$VN" : v*'\(.*\)')
32 if test -r $GVF
33 then
34 VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
35 else
36 VC=unset
38 test "$VN" = "$VC" || {
39 echo >&2 "GIT_VERSION = $VN"
40 echo "GIT_VERSION = $VN" >$GVF