]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
cephmetrics: Add support for versioning with git tags 833/head
authorBoris Ranto <branto@redhat.com>
Wed, 16 Aug 2017 10:55:47 +0000 (12:55 +0200)
committerBoris Ranto <branto@redhat.com>
Wed, 16 Aug 2017 10:56:28 +0000 (12:56 +0200)
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 <branto@redhat.com>
cephmetrics/build/build_rpm

index 31070fc8c260c513501258a9e311695d0cc6ed79..c84a9ae62a8a8ab72847bffdb30a90207907ed57 100644 (file)
@@ -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