From 2847b05527e18ada7d829fdf7649e7132f87b51f Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Wed, 16 Aug 2017 12:55:47 +0200 Subject: [PATCH] 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 --- cephmetrics/build/build_rpm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 -- 2.47.3