1- BRANCH_NAME = $(shell git name-rev --name-only HEAD)
1+ BRANCH_NAME = $(shell git rev-parse --abbrev-ref HEAD)
2+
3+ ifeq ($(BRANCH_NAME ) ,HEAD)
4+ NAME = $(shell git name-rev --name-only HEAD)
5+ NAME_PARTS = $(subst ~, ,$(subst ^, ,$(NAME ) ) )
6+ ifeq ($(words $(NAME_PARTS ) ) ,1)
7+ TAG = 1
8+ else
9+ TAG = 0
10+ VERSION_BRANCH = $(shell git rev-parse --short HEAD)
11+ endif
12+ else
13+ TAG = 0
214UPSTREAM = $(shell git config --get branch.$(BRANCH_NAME ) .merge)
315ifeq ($(UPSTREAM ) ,)
416BRANCH ?= $(BRANCH_NAME )
517else
618BRANCH ?= $(shell git rev-parse --symbolic-full-name --abbrev-ref @{upstream})
719endif
8- VERSION_BRANCH = $(shell echo "$(BRANCH_NAME ) " | tr A-Z-/ a-z.)
20+ VERSION_BRANCH = $(shell basename "$(BRANCH_NAME ) " | tr A-Z-_ a-z.)
21+ endif # for ifeq ($(BRANCH_NAME),HEAD)
922
1023DESCRIBE = $(shell git describe --tags --long --always $(BRANCH ) )
1124DESC_LIST = $(subst -, ,$(DESCRIBE ) )
@@ -18,13 +31,12 @@ SHA = $(word 1,$(DESC_LIST))
1831endif
1932
2033REV_SUFFIX = $(or\
34+ $(if $(findstring 1,$(TAG ) ) ,"") ,\
2135 $(if $(findstring master,$(BRANCH ) ) ,"") ,\
2236 $(if $(findstring develop,$(BRANCH ) ) ,.dev$(COUNT ) ) ,\
2337 $(if $(findstring release/,$(BRANCH ) ) ,rc$(COUNT ) ) ,\
2438 $(if $(findstring hotfix/,$(BRANCH ) ) ,rc$(COUNT ) ) ,\
25- $(if $(findstring feature/,$(BRANCH ) ) ,.dev$(COUNT ) +$(VERSION_BRANCH ) ) ,\
26- $(if $(findstring bugfix/,$(BRANCH ) ) ,.dev$(COUNT ) +$(VERSION_BRANCH ) ) ,\
27- .dev0+badbranch\
39+ .dev$(COUNT ) +$(VERSION_BRANCH ) \
2840 )
2941BASE_VERSION = $(shell cat VERSION)
3042VERSION = $(BASE_VERSION )$(REV_SUFFIX )
0 commit comments