waf: Fix how waf gets build id

Use git to output revision shortlen SHA

Signed-off-by: Prasanna Santhanam <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c5a25a2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c5a25a2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c5a25a2b

Branch: refs/heads/javelin
Commit: c5a25a2b338c03ef6b632ea6f2be4c095eee8d28
Parents: 465e046
Author: Rohit Yadav <[email protected]>
Authored: Fri Sep 14 19:19:34 2012 +0530
Committer: Prasanna Santhanam <[email protected]>
Committed: Fri Sep 14 19:39:35 2012 +0530

----------------------------------------------------------------------
 wscript |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c5a25a2b/wscript
----------------------------------------------------------------------
diff --git a/wscript b/wscript
index f1c9b62..08b1cc6 100644
--- a/wscript
+++ b/wscript
@@ -161,7 +161,7 @@ def svninfo(*args):
 
 def gitinfo(dir=None):
        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:
                if e.errno == 2: return '' # svn command is not installed
                raise
@@ -194,7 +194,7 @@ def allgitinfo():
        
        return t + "\n\ncloustack-proprietary:\n" + u
 
-def _getbuildnumber(): # FIXME implement for git
+def _getbuildnumber():
        n = Options.options.BUILDNUMBER
        if n:
                # 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()
                return n
        else:
-               # Try to guess the SVN revision number by calling SVN info.
-               stdout = svninfo()
+               # Try to guess the Git revision number
+               stdout = gitinfo()
                if not stdout: return ''
                # Filter lines.
                rev = [ x for x in stdout.splitlines() if x.startswith('SVN 
Revision') ]

Reply via email to