waf: Fix how waf gets build id

Use git to output revision shortlen SHA

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Rohit Yadav 2012-09-14 19:19:34 +05:30 committed by Prasanna Santhanam
parent 465e0466c3
commit c5a25a2b33

View File

@ -161,7 +161,7 @@ def svninfo(*args):
def gitinfo(dir=None): def gitinfo(dir=None):
if dir and not _isdir(dir): return '' if dir and not _isdir(dir): return ''
try: p = _Popen(['git','remote','show','-n','origin'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir) try: p = _Popen(['git','rev-parse', '--short', 'HEAD'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir)
except OSError,e: except OSError,e:
if e.errno == 2: return '' # svn command is not installed if e.errno == 2: return '' # svn command is not installed
raise raise
@ -194,7 +194,7 @@ def allgitinfo():
return t + "\n\ncloustack-proprietary:\n" + u return t + "\n\ncloustack-proprietary:\n" + u
def _getbuildnumber(): # FIXME implement for git def _getbuildnumber():
n = Options.options.BUILDNUMBER n = Options.options.BUILDNUMBER
if n: if n:
# luntbuild prepends "build-" to the build number. we work around this here: # luntbuild prepends "build-" to the build number. we work around this here:
@ -203,8 +203,8 @@ def _getbuildnumber(): # FIXME implement for git
if n.startswith("$Revision:"): n = n[11:-2].strip() if n.startswith("$Revision:"): n = n[11:-2].strip()
return n return n
else: else:
# Try to guess the SVN revision number by calling SVN info. # Try to guess the Git revision number
stdout = svninfo() stdout = gitinfo()
if not stdout: return '' if not stdout: return ''
# Filter lines. # Filter lines.
rev = [ x for x in stdout.splitlines() if x.startswith('SVN Revision') ] rev = [ x for x in stdout.splitlines() if x.startswith('SVN Revision') ]