Code

version-gen.sh: Slightly improved robustness against errors.
[template.git] / version-gen.sh
1 #! /bin/sh
3 DEFAULT_VERSION="0.0.0.git"
5 VERSION="$( git describe --tags 2> /dev/null \
6         | sed -e 's/foobar-//' || true )"
8 if test -z "$VERSION"; then
9         VERSION="$DEFAULT_VERSION"
10 else
11         git update-index -q --refresh || true
12         if test -n "$( git diff-index --name-only HEAD || true )"; then
13                 VERSION="$VERSION-dirty"
14         fi
15 fi
17 VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )"
18 echo -n "$VERSION"