From: Boris Ranto Date: Wed, 16 Aug 2017 10:55:47 +0000 (+0200) Subject: cephmetrics: Add support for versioning with git tags X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F833%2Fhead;p=ceph-build.git cephmetrics: Add support for versioning with git tags This will try to use git describe to get the current version and release and fall back to the old method if HEAD is not part of any tag. Signed-off-by: Boris Ranto --- diff --git a/cephmetrics/build/build_rpm b/cephmetrics/build/build_rpm index 31070fc8..c84a9ae6 100644 --- a/cephmetrics/build/build_rpm +++ b/cephmetrics/build/build_rpm @@ -26,8 +26,11 @@ fi ## Get some basic information about the system and the repository RELEASE="$(lsb_release --short -r | cut -d '.' -f 1)" # sytem release -VERSION="0.1" -REVISION="$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)" +DESCRIBE="$(git describe --tags 2>/dev/null | cut -b 2-)" +test -z "$DESCRIBE" && DESCRIBE="0.1-$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)" +VERSION="$(echo $DESCRIBE | cut -d - -f 1)" +REVISION="$(echo $DESCRIBE | cut -s -d - -f 2-)" +test -z "$REVISION" && REVISION=0 RPM_RELEASE=$(echo $REVISION | tr '-' '_') # the '-' has a special meaning