aboutsummaryrefslogblamecommitdiffstats
path: root/build-aux/git-version-gen
blob: bf4230aae8d4936e7f032412908a2e6788dffe83 (plain) (tree)
1
2
3
4
5
6
7
8
9







                                             
                 



                
                                             

                                                                         
                                                         

  
                                                       
 
              
#!/bin/sh

if [ "$#" -ne 1 ]
then
  echo "usage: git-version-gen <verfile>" >&2
  exit 1
fi

DEF_VER=4.2.2.dev
VERFILE="$1"

if [ -d '.git' ]
then
  git update-index --refresh > /dev/null 2>&1
  VERSION=`git describe --abbrev=4 --match='v[0-9]*' --dirty 2>/dev/null`
  VERSION=`echo "$VERSION" | sed 's/^v//'`
  [ -n "$VERSION" ] && printf "%s" "$VERSION" >"$VERFILE"
fi

[ -f "$VERFILE" ] || printf "%s" "$DEF_VER" >"$VERFILE"

cat "$VERFILE"