1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-09-19 22:25:55 -04:00

🔨 Detect if Git repo exists in Makefile

This commit is contained in:
makeworld 2020-09-02 13:51:48 -04:00
parent d9c6c92d98
commit 811868f06b

View File

@ -1,3 +1,6 @@
GIT_EXISTS := $(shell git status > /dev/null 2>&1 ; echo $$?)
ifeq ($(GIT_EXISTS), 0)
ifeq ($(shell git tag --points-at HEAD),) ifeq ($(shell git tag --points-at HEAD),)
# Not currently on a tag # Not currently on a tag
VERSION := $(shell git describe --tags | sed 's/-.*/-next/') # v1.2.3-next VERSION := $(shell git describe --tags | sed 's/-.*/-next/') # v1.2.3-next
@ -7,6 +10,7 @@ else
endif endif
COMMIT := $(shell git rev-parse --verify HEAD) COMMIT := $(shell git rev-parse --verify HEAD)
endif
INSTALL := install -o root -g root INSTALL := install -o root -g root
INSTALL_DIR := /usr/local/bin INSTALL_DIR := /usr/local/bin
@ -17,6 +21,10 @@ DESKTOP_DIR := /usr/share/applications
all: build all: build
build: build:
ifneq ($(GIT_EXISTS), 0)
# No Git repo
$(error No Git repo was found, which is needed to compile the commit and version)
endif
@echo "Downloading dependencies" @echo "Downloading dependencies"
@go env -w GO111MODULE=on ; go mod download @go env -w GO111MODULE=on ; go mod download
@echo "Building binary" @echo "Building binary"