[dev] [PATCH 1/1] update version handling to work with tags or without git

From: Christian Hesse <list_AT_eworm.de>
Date: Fri, 21 Aug 2015 16:39:23 +0200

From: Christian Hesse <mail_AT_eworm.de>

Signed-off-by: Christian Hesse <mail_AT_eworm.de>
---
 config.mk | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/config.mk b/config.mk
index 85ddc17..5528064 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -3,13 +3,20 @@ HAVE_ACL=0
 HAVE_SELINUX=0
 
 # vis version
-# we have no tags in git, so just use revision count an hash for now
-GITREVCOUNT = "$(shell git rev-list --count master 2>/dev/null)"
-GITHASH = "$(shell git log -1 --format="%h" 2>/dev/null)"
-ifeq (${GITREVCOUNT},)
-	VERSION = devel
-else
+# try to get a tag and hash first
+GITHASH = $(shell git log -1 --format='%h' 2>/dev/null)
+GITTAG = $(shell git describe --abbrev=0 --tags 2>/dev/null)
+ifneq ($(GITTAG),)
+	# we have a tag and revcount from there
+	GITREVCOUNT = "$(shell git rev-list --count ${GITTAG}.. 2>/dev/null)"
+	VERSION = "${GITTAG}.r${GITREVCOUNT}.g${GITHASH}"
+else ifneq ($(GITHASH),)
+	# we have no tags in git, so just use revision count an hash for now
+	GITREVCOUNT = "$(shell git rev-list --count master)"
 	VERSION = "0.r${GITREVCOUNT}.g${GITHASH}"
+else
+	# this is used when no git is available, e.g. for release tarball
+	VERSION = "0.0"
 endif
 
 # Customize below to fit your system
-- 
2.5.0
Received on Fri Aug 21 2015 - 16:39:23 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 21 2015 - 16:48:09 CEST