Browse Source

mk/targets.mk: Add version fallback for tag-less repos

* mk/targets.mk (ORGVERSION, GITVERSION): Get version from lisp/org.el
header if it can't be retrieved from git-describe.

As of elpa.git's ee03829f90 (Finalize the new master branch,
2020-12-14), org-release and org-git-version are empty strings in
https://elpa.gnu.org/packages/org-*.tar files.  This is because the
new setup executes `make autoloads info' in an elpa.git worktree with
an Org branch checked out, but elpa.git of course doesn't have Org's
release tags.

Maintaining the org.el version header has been a point of contention
in the past [1], but the header has been there for a while now.  Use
it to avoid the above elpa.git issue.  In the case of the master
branch, the org-release value generated in a tag-less repo will have a
different version than the one from a regular repo because org.el's
version header has a "-dev" suffix, but that's still better than an
empty version.

[1] For example: https://orgmode.org/list/87zj1uhix6.fsf@gmx.us/

Reported-by: Pierre Langlois <pierre.langlois@gmx.com>
Ref: https://orgmode.org/list/87y2hi9qev.fsf@gmx.com
Kyle Meyer 7 months ago
parent
commit
61336f80dc
1 changed files with 9 additions and 1 deletions
  1. 9 1
      mk/targets.mk

+ 9 - 1
mk/targets.mk

@@ -11,8 +11,16 @@ INSTSUB       = $(SUBDIRS:%=install-%)
 ORG_MAKE_DOC ?= info html pdf
 
 ifneq ($(wildcard .git),)
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
   ORGVERSION ?= $(subst release_,,$(shell git describe --match release\* --abbrev=0 HEAD))
+  ifeq ($(ORGVERSION),)
+    # In elpa.git, there are no tags available.  Fall back to using
+    # the org.el header.
+    ORGVERSION := $(shell $(BATCH) --eval "(require 'lisp-mnt)" \
+      --visit lisp/org.el --eval '(princ (lm-header "version"))')
+    GITVERSION ?= $(ORGVERSION)-g$(shell git rev-parse --short=6 HEAD)
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk