0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

inject git-describe version into org.el during install

* lisp/org.el (org-git-version): placeholder for recording the Git
	version of org during install
	* lisp/org.el (org-version): initialize local git-version with
	placeholder and fall through using it when org is not installed in
	a Git repository
This commit is contained in:
Achim Gratz 2011-07-17 16:54:47 +02:00
parent a5cb04dcd8
commit f29ef857ae
2 changed files with 14 additions and 4 deletions

View file

@ -2,6 +2,11 @@ ifeq ($(MAKELEVEL), 0)
$(error This make needs to be started as a sub-make from the toplevel directory.)
endif
GITVERSION = $(shell git describe --abbrev=6 HEAD)
ifneq ($(shell git status -uno --porcelain), '')
GITVERSION := $(GITVERSION).dirty
endif
LISPO = org-install.el
LISPF = $(subst $(LISPO),,$(wildcard *.el))
LISPC = $(LISPF:%el=%elc)
@ -26,6 +31,8 @@ org-install.el: $(LISPC)
install: $(LISPF) compile autoloads
if [ ! -d $(lispdir) ]; then $(MKDIR) $(lispdir); else true; fi ;
$(CP) $(LISPC) $(LISPF) $(LISPO) $(lispdir)
perl -i -pe 's/^(\(defconst org-git-version ).*/\1 "$(GITVERSION)"/;' $(lispdir)/org.el
$(MAKE) $(lispdir)/org.elc
clean:
$(RM) $(LISPC)

View file

@ -212,6 +212,10 @@ identifier."
(defconst org-version "7.8.09"
"The version number of the file org.el.")
(defconst org-git-version "N/A"
"The Git version of org-mode. Inserted by installing org-mode
or when a release is made.")
;;;###autoload
(defun org-version (&optional here)
"Show the org-mode version in the echo area.
@ -219,7 +223,7 @@ With prefix arg HERE, insert it at point."
(interactive "P")
(let* ((origin default-directory)
(version org-version)
(git-version)
(git-version org-git-version)
(dir (concat (file-name-directory (locate-library "org")) "../" )))
(when (and (file-exists-p (expand-file-name ".git" dir))
(executable-find "git"))
@ -232,12 +236,11 @@ With prefix arg HERE, insert it at point."
(setq git-version (buffer-substring (point) (point-at-eol))))
(subst-char-in-string ?- ?. git-version t)
(when (string-match "\\S-"
(shell-command-to-string
"git diff-index --name-only HEAD --"))
(shell-command-to-string "git status -uno --porcelain"))
(setq git-version (concat git-version ".dirty")))
(setq version (concat version " (" git-version ")"))))
(cd origin)))
(setq version (format "Org-mode version %s" version))
(setq version (format "Org-mode version %s (%s)" version git-version))
(if here (insert version))
(message version)))