[pypy-svn] pypy default: Updated git version info to match hg's tag/branch.
tav
commits-noreply at bitbucket.org
Thu Mar 3 16:59:29 CET 2011
Author: tav <tav at espians.com>
Branch:
Changeset: r42409:b9887cd8aab0
Date: 2011-03-03 15:59 +0000
http://bitbucket.org/pypy/pypy/changeset/b9887cd8aab0/
Log: Updated git version info to match hg's tag/branch.
diff --git a/pypy/tool/version.py b/pypy/tool/version.py
--- a/pypy/tool/version.py
+++ b/pypy/tool/version.py
@@ -27,7 +27,7 @@
if gitexe:
try:
p = Popen(
- [str(gitexe), 'describe', '--tags', '--always'],
+ [str(gitexe), 'rev-parse', 'HEAD'],
stdout=PIPE, stderr=PIPE
)
except OSError, e:
@@ -36,15 +36,25 @@
if p.wait() != 0:
maywarn(p.stderr.read(), 'Git')
return default_retval
- tag = p.stdout.read().strip()
+ revision_id = p.stdout.read().strip()[:12]
p = Popen(
- [str(gitexe), 'rev-parse', 'HEAD'],
+ [str(gitexe), 'describe', '--tags', '--exact-match'],
stdout=PIPE, stderr=PIPE
)
if p.wait() != 0:
- maywarn(p.stderr.read(), 'Git')
- return 'PyPy', tag, '?'
- return 'PyPy', tag, p.stdout.read().strip()[:12]
+ p = Popen([str(gitexe), 'branch'], stdout=PIPE, stderr=PIPE)
+ if p.wait() != 0:
+ maywarn(p.stderr.read(), 'Git')
+ return 'PyPy', '?', revision_id
+ branch = '?'
+ for line in p.stdout.read().strip().split('\n'):
+ if line.startswith('* '):
+ branch = line[1:].strip()
+ if branch == '(no branch)':
+ branch = '?'
+ break
+ return 'PyPy', branch, revision_id
+ return 'PyPy', p.stdout.read().strip(), revision_id
# Fallback to trying Mercurial.
if hgexe is None:
More information about the Pypy-commit
mailing list