File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,19 @@ clean:
4545# ###########################################################
4646# build section
4747# ###########################################################
48+ # Parse the version using git, with fallbacks as follows:
49+ # - git describe (i.e. vX.Y.Z-<sha>)
50+ # - <branch>-<sha>
51+ # - <sha>-dev
52+ # - Unversioned binary
4853GIT_VERSION := $(shell git describe --dirty 2>/dev/null)
4954ifndef GIT_VERSION
5055 GIT_BRANCH := $(shell git branch --show-current)
56+ GIT_SHA := $(shell git rev-parse --short HEAD)
5157 ifdef GIT_BRANCH
52- GIT_VERSION := $(GIT_BRANCH ) -$(shell git rev-parse --short HEAD )
53- else
54- GIT_VERSION := $(shell git rev-parse --short HEAD ) -dev
58+ GIT_VERSION := $(GIT_BRANCH ) -$(GIT_SHA )
59+ else ifdef GIT_SHA
60+ GIT_VERSION := $(GIT_SHA ) -dev
5561 endif
5662endif
5763GO_LDFLAGS ?= -X 'main.Version=$(GIT_VERSION ) '
You can’t perform that action at this time.
0 commit comments