>From 28c596320f48e4606f8eaf69fdc1c83fb084749e Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Sun, 15 Jan 2023 14:55:11 -0500 Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones If Org is being built from a shallow clone, tags are not locally available. Query the upstream remote via git ls-remote and parse the output. Note this will result in a "n/a" indicator in org-version where the number of commits since the last tag is usually present. e.g. "release_9.6.1-n/a-gabc123" --- mk/targets.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mk/targets.mk b/mk/targets.mk index 4435daa91..300fc8e0b 100644 --- a/mk/targets.mk +++ b/mk/targets.mk @@ -14,7 +14,14 @@ ifneq ($(wildcard .git),) # Use the org.el header. ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \ --visit lisp/org.el --eval '(princ (lm-header "version"))')) - GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD) + ifneq ($(wildcard .git/shallow),) + REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1)) + COMMIT := $(shell echo $(firstword $(REMOTETAGS)) | cut -c 1-6) + TAGPREFIX := $(subst refs/tags/,,$(lastword $(REMOTETAGS))) + GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX)) + else + GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD) + endif GITSTATUS ?= $(shell git status -uno --porcelain) else -include mk/version.mk -- 2.39.0