Skip to content

Commit 232aa36

Browse files
committed
Check for .git directory; use placeholders if missing.
This happens when the code is in another SCM or obtained from a tarball, e.g.: https://github.com/haproxytech/dataplaneapi/archive/refs/tags/<tag>.tar.gz
1 parent 8ec3bde commit 232aa36

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
DATAPLANEAPI_PATH?=$(shell pwd)
2+
ifeq ($(wildcard .git),)
3+
GIT_REPO?= unknown
4+
GIT_HEAD_COMMIT=unknown
5+
GIT_LAST_TAG= unknown
6+
GIT_TAG_COMMIT= unknown
7+
GIT_MODIFIED1= unknown
8+
GIT_MODIFIED2= unknown
9+
else
210
GIT_REPO?=$(shell git config --get remote.origin.url)
311
GIT_HEAD_COMMIT=$(shell git rev-parse --short HEAD)
412
GIT_LAST_TAG=$(shell git describe --abbrev=0 --tags)
513
GIT_TAG_COMMIT=$(shell git rev-parse --short ${GIT_LAST_TAG})
614
GIT_MODIFIED1=$(shell git diff "${GIT_HEAD_COMMIT}" "${GIT_TAG_COMMIT}" --quiet || echo .dev)
715
GIT_MODIFIED2=$(shell git diff --quiet || echo .dirty)
16+
endif
817
GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
918
SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
1019
BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')

0 commit comments

Comments
 (0)