From 1a62f6efae96b7472cea698564b5b7ae731e3e02 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 26 Sep 2022 10:09:30 +0200 Subject: fix(Makefile): fix the `make commit-template` target make commit template expects the CWD of make to be a git repository. While this is true most of the time, there are cases where we use the Makefile just for install dependencies (e.g. https://github.com/FDio/hicn/blob/master/Dockerfile.dev#L22) and in that case we do not copy the .git folder. The solution is to check if the current make directory is actually a .git repository. Ticket: HICN-796 Signed-off-by: Mauro Sardara Change-Id: I12912c76c9ddfa3b7a19d0faf8c84b178ca728bf Signed-off-by: Mauro Sardara --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bc4d63774..6c3f9617a 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,11 @@ OS_ID = $(shell grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\ OS_VERSION_ID = $(shell grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') endif +# +# Git Repo detection +# +GIT_INFO = $(shell git -C . rev-parse 2>/dev/null; echo $$?) + ifeq ($(shell uname),Darwin) BUILD_HICNPLUGIN := OFF PUNTING := OFF @@ -85,14 +90,16 @@ help: .PHONY = commit-template commit-template: - @git config commit.template $(COMMIT_TEMPLATE_FILE) +ifeq ($(GIT_INFO),0) + git config commit.template $(COMMIT_TEMPLATE_FILE) +endif .PHONY = vpp-dep vpp-dep: VERSION_PATH=$(VERSIONFILE) sudo -E $(SHELL) scripts/install-vpp.sh .PHONY = dep -dep: vpp-dep #commit-template +dep: vpp-dep ifeq ($(shell uname),Darwin) brew install $(MACOS_DEPENDS) else ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID)) -- cgit 1.2.3-korg