mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Create a meaningful and sortable build number from the current git revision.
This commit is contained in:
@@ -744,40 +744,36 @@ def getSvnRev():
|
|||||||
# Some helpers for the code below
|
# Some helpers for the code below
|
||||||
def _getDate():
|
def _getDate():
|
||||||
import datetime
|
import datetime
|
||||||
today = datetime.date.today()
|
now = datetime.datetime.now()
|
||||||
return "%d%02d%02d" % (today.year, today.month, today.day)
|
return "%d%02d%02d.%02d%02d" % (now.year, now.month, now.day, now.hour, now.minute)
|
||||||
|
|
||||||
def _getSvnRevision():
|
def _getSvnRevision():
|
||||||
|
if not os.path.exists('.svn'):
|
||||||
|
return None
|
||||||
svnrev = None
|
svnrev = None
|
||||||
try:
|
try:
|
||||||
rev = runcmd('svnversion', getOutput=True, echoCmd=False)
|
rev = runcmd('svnversion', getOutput=True, echoCmd=False)
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
if rev != 'exported':
|
svnrev = rev.split(':')[0]
|
||||||
svnrev = rev.split(':')[0]
|
|
||||||
return svnrev
|
return svnrev
|
||||||
|
|
||||||
def _getGitSvnRevision():
|
def _getGitRevision():
|
||||||
svnrev = None
|
|
||||||
try:
|
try:
|
||||||
info = runcmd('git svn info', getOutput=True, echoCmd=False)
|
revcount = runcmd('git rev-list --count HEAD', getOutput=True, echoCmd=False)
|
||||||
|
revhash = runcmd('git rev-parse --short HEAD', getOutput=True, echoCmd=False)
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
for line in info.splitlines():
|
return "{}.{}".format(revcount, revhash)
|
||||||
if line.startswith('Revision:'):
|
|
||||||
svnrev = line.split(' ')[-1]
|
# Try getting the revision number from SVN, or GIT, or just fall back
|
||||||
break
|
|
||||||
return svnrev
|
|
||||||
|
|
||||||
# Try getting the revision number from SVN, or GIT SVN, or just fall back
|
|
||||||
# to the date.
|
# to the date.
|
||||||
svnrev = _getSvnRevision()
|
svnrev = _getSvnRevision()
|
||||||
if not svnrev:
|
if not svnrev:
|
||||||
svnrev = _getGitSvnRevision()
|
svnrev = _getGitRevision()
|
||||||
if not svnrev:
|
if not svnrev:
|
||||||
svnrev = _getDate()
|
svnrev = _getDate()
|
||||||
msg('WARNING: Unable to determine SVN revision, using date (%s) instead.' % svnrev)
|
msg('WARNING: Unable to determine SVN revision, using date (%s) instead.' % svnrev)
|
||||||
|
|
||||||
return svnrev
|
return svnrev
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user