[SCM] morituri/master: use a built REVISION file as a backup revision source

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:10:10 UTC 2014


The following commit has been merged in the master branch:
commit df0daefa27f6911167c73424ccac1c3d9480abf2
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Wed Jul 31 12:18:41 2013 +0200

    use a built REVISION file as a backup revision source

diff --git a/.gitignore b/.gitignore
index ff01510..0fbf43a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ install-sh
 missing
 morituri.spec
 py-compile
+REVISION
diff --git a/Makefile.am b/Makefile.am
index dc8e9f7..8d8d232 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4
 
 SUBDIRS = morituri bin etc doc m4 misc
 
-EXTRA_DIST = morituri.spec morituri.doap RELEASE README HACKING
+EXTRA_DIST = morituri.spec morituri.doap RELEASE README HACKING REVISION
 
 SOURCES = $(top_srcdir)/morituri/*.py $(top_srcdir)/morituri/*/*.py
 
@@ -38,6 +38,9 @@ PYCHECKER_BLACKLIST = \
 release: dist
 	make $(PACKAGE)-$(VERSION).tar.bz2.md5
 
+REVISION: $(top_srcdir)/.git
+	$(PYTHON) -c 'from morituri.configure import configure; print configure.revision' > REVISION
+
 # generate md5 sum files
 %.md5: %
 	md5sum $< > $@
diff --git a/morituri/common/common.py b/morituri/common/common.py
index aa964e9..1a30eaf 100644
--- a/morituri/common/common.py
+++ b/morituri/common/common.py
@@ -339,10 +339,29 @@ def getRevision():
     Get a revision tag for the current git source tree.
 
     Appends -modified in case there are local modifications.
+
+    If this is not a git tree, return the top-level REVISION contents instead.
+
+    Finally, return unknown.
     """
-    describe = commands.getoutput('git describe')
+    topsrcdir = os.path.join(os.path.dirname(__file__), '..', '..')
+
+    # only use git if our src directory looks like a git checkout
+    # if you run git regardless, it recurses up until it finds a .git,
+    # which may be higher than your current source tree
+    if os.path.exists(os.path.join(topsrcdir, '.git')):
+
+        status, describe = commands.getstatusoutput('git describe')
+        if status == 0:
+            if commands.getoutput('git diff-index --name-only HEAD --'):
+                describe += '-modified'
+
+            return describe
 
-    if commands.getoutput('git diff-index --name-only HEAD --'):
-        describe += '-modified'
+    # check for a top-level REIVISION file
+    path = os.path.join(topsrcdir, 'REVISION')
+    if os.path.exists(path):
+        revision = open(path).read().strip()
+        return revision
 
-    return describe
+    return '(unknown)'

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list