Skip to content

Commit 680d005

Browse files
dhaiducekopenshift-merge-robot
authored andcommitted
Don't set version if SHA is empty
ref: #118 ref: https://issues.redhat.com/browse/ACM-5803 Signed-off-by: Dale Haiducek <[email protected]>
1 parent a596e0a commit 680d005

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff 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
4853
GIT_VERSION := $(shell git describe --dirty 2>/dev/null)
4954
ifndef 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
5662
endif
5763
GO_LDFLAGS ?= -X 'main.Version=$(GIT_VERSION)'

0 commit comments

Comments
 (0)