Browse Source

Add git version number to org-version information

Adds the output of 'git describe' to the org-version string if we are running
from a git repository.  This identifies exactly what commit is checked out in
the org-mode git repository when reporting the org-mode version number.

org-version returns something like:

    Org-mode version 6.29trans (release_6.29c.42.g5996)

which shows 6.29trans (somewhere after the last release tag) which
is 42 commits after release_6.29c at git commit 5996.

The git describe information is not included if org mode is not
running from a git repository.
Bernt Hansen 11 years ago
parent
commit
a5e87a4723
1 changed files with 16 additions and 4 deletions
  1. 16 4
      lisp/org.el

+ 16 - 4
lisp/org.el

@@ -102,10 +102,22 @@
   "Show the org-mode version in the echo area.
 With prefix arg HERE, insert it at point."
   (interactive "P")
-  (let ((version (format "Org-mode version %s" org-version)))
-    (message version)
-    (if here
-	(insert version))))
+  (let* ((org-version org-version)
+	 (dir (concat (file-name-directory (locate-library "org")) "../" )))
+    (if (file-exists-p (expand-file-name ".git" dir))
+	(progn
+	 (shell-command (concat "cd " dir " && git describe --abbrev=4 HEAD"))
+	 (save-excursion
+	   (set-buffer "*Shell Command Output*")
+	   (goto-char (point-min))
+	   (replace-regexp "-" ".")
+	   (goto-char (point-min))
+	   (re-search-forward "[^\n]+")
+	   (setq org-version (concat org-version " (" (match-string 0) ")")))))
+    (let ((version (format "Org-mode version %s" org-version)))
+      (message version)
+      (if here
+	  (insert version)))))
 
 ;;; Compatibility constants