X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=version-gen.sh;h=57300717c1ca9597259683368b458f8e3be92d2d;hb=2cc91bc2918f6ee9c0ab1ae3fd5b0c8386786867;hp=a54f2af2fdaec5e36a91847c3b8f2268535de5be;hpb=26378e37405d8c3a1abbf3d96d7487b7dc521e27;p=template.git diff --git a/version-gen.sh b/version-gen.sh index a54f2af..5730071 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -2,13 +2,14 @@ DEFAULT_VERSION="0.0.0.git" -VERSION="$( git describe --tags 2> /dev/null | sed -e 's/foobar-//' )" +VERSION="$( git describe --tags 2> /dev/null \ + | sed -e 's/foobar-//' || true )" if test -z "$VERSION"; then VERSION="$DEFAULT_VERSION" else - git update-index -q --refresh - if test -n "$( git diff-index --name-only HEAD )"; then + git update-index -q --refresh || true + if test -n "$( git diff-index --name-only HEAD || true )"; then VERSION="$VERSION-dirty" fi fi @@ -16,3 +17,23 @@ fi VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )" echo -n "$VERSION" +OLD_VERSION="" +if test -e version; then + OLD_VERSION=$( sed -ne 's/^VERSION="\(.*\)"/\1/p' version ) +fi + +if test "$OLD_VERSION" != "$VERSION"; then + VERSION_MAJOR=$( echo $VERSION | cut -d'.' -f1 ) + VERSION_MINOR=$( echo $VERSION | cut -d'.' -f2 ) + VERSION_PATCH=$( echo $VERSION | cut -d'.' -f3 ) + VERSION_EXTRA="\"$( echo $VERSION | cut -d'.' -f4- )\"" + ( + echo "VERSION=\"$VERSION\"" + echo "VERSION_MAJOR=$VERSION_MAJOR" + echo "VERSION_MINOR=$VERSION_MINOR" + echo "VERSION_PATCH=$VERSION_PATCH" + echo "VERSION_EXTRA=\"$VERSION_EXTRA\"" + echo "VERSION_STRING=\"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH\"" + ) > version +fi +