From f29ef857ae7a3ad4d191a3c167f9c96d8faf61bd Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Sun, 17 Jul 2011 16:54:47 +0200 Subject: [PATCH] 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 --- lisp/Makefile | 7 +++++++ lisp/org.el | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/Makefile b/lisp/Makefile index b14d6f131..963d08c8a 100644 --- a/lisp/Makefile +++ b/lisp/Makefile @@ -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) diff --git a/lisp/org.el b/lisp/org.el index b2b140c48..c76103878 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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)))