use a built REVISION file as a backup revision source

This commit is contained in:
Thomas Vander Stichele
2013-07-31 12:18:41 +02:00
parent ad2e89ed97
commit df0daefa27
3 changed files with 28 additions and 5 deletions

1
.gitignore vendored
View File

@@ -14,3 +14,4 @@ install-sh
missing
morituri.spec
py-compile
REVISION

View File

@@ -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 $< > $@

View File

@@ -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__), '..', '..')
if commands.getoutput('git diff-index --name-only HEAD --'):
describe += '-modified'
# 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')):
return describe
status, describe = commands.getstatusoutput('git describe')
if status == 0:
if commands.getoutput('git diff-index --name-only HEAD --'):
describe += '-modified'
return describe
# 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 '(unknown)'