]>
Commit | Line | Data |
---|---|---|
9b88fcef JH |
1 | #!/bin/sh |
2 | ||
3 | GVF=GIT-VERSION-FILE | |
4baff505 | 4 | DEF_VER=v1.3.GIT |
9b88fcef | 5 | |
181129d2 PA |
6 | # First try git-describe, then see if there is a version file |
7 | # (included in release tarballs), then default | |
374dfaa2 UZ |
8 | if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then |
9 | VN=$(echo "$VN" | sed -e 's/-/./g'); | |
0b8b051c JH |
10 | elif test -f version |
11 | then | |
374dfaa2 | 12 | VN=$(cat version) || VN="$DEF_VER" |
0b8b051c JH |
13 | else |
14 | VN="$DEF_VER" | |
374dfaa2 | 15 | fi |
181129d2 PA |
16 | |
17 | VN=$(expr "$VN" : v*'\(.*\)') | |
eb858c60 JH |
18 | |
19 | dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty= | |
20 | case "$dirty" in | |
21 | '') | |
22 | ;; | |
23 | *) | |
24 | VN="$VN-dirty" ;; | |
25 | esac | |
26 | ||
9b88fcef JH |
27 | if test -r $GVF |
28 | then | |
29 | VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) | |
30 | else | |
31 | VC=unset | |
32 | fi | |
33 | test "$VN" = "$VC" || { | |
34 | echo >&2 "GIT_VERSION = $VN" | |
35 | echo "GIT_VERSION = $VN" >$GVF | |
36 | } | |
37 | ||
38 |