summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2019-02-13 10:50:50 +1100
committerChris Johns <chrisj@rtems.org>2019-02-13 10:56:19 +1100
commitd721375610a5d511515cb7bf165d7fa8c7dd32c8 (patch)
treeefb3076b322d21f4d327d1263e99a9349b0ea1a7 /common
parent5d8b0ddd0ac055b5edb569f119e8a4c744fd1aae (diff)
downloadrtems-docs-d721375610a5d511515cb7bf165d7fa8c7dd32c8.tar.bz2
waf: Fix version.py to support older versions of git.
Diffstat (limited to 'common')
-rw-r--r--common/version.py51
1 files changed, 34 insertions, 17 deletions
diff --git a/common/version.py b/common/version.py
index 3ba9454..9beb3e7 100644
--- a/common/version.py
+++ b/common/version.py
@@ -69,14 +69,31 @@ _version = 'invalid'
_date = 'unknown date'
_released = False
-def _pretty_day(day):
+def _pretty_day(ctx, date):
+ ''' Format is YYYY-MM-DD'''
+ import datetime
+ ds = date.split('-')
+ if len(ds) != 3:
+ ctx.fatal('invalid date format from git: %s' % (date))
+ try:
+ year = int(ds[0])
+ except:
+ ctx.fatal('invalid date format from git, converting year: %s' % (date))
+ try:
+ month = int(ds[1])
+ except:
+ ctx.fatal('invalid date format from git, converting month: %s' % (date))
+ try:
+ day = int(ds[2])
+ except:
+ ctx.fatal('invalid date format from git, converting day: %s' % (date))
+ try:
+ when = datetime.date(year, month, day)
+ except:
+ ctx.fatal('invalid date format from git: %s' % (date))
if day == 3:
s = 'rd'
- elif day == 11:
- s = 'th'
- elif day == 12:
- s = 'th'
- elif day == 13:
+ elif day == 11 or day == 12:
s = 'th'
elif day % 10 == 1:
s = 'st'
@@ -84,7 +101,10 @@ def _pretty_day(day):
s = 'nd'
else:
s = 'th'
- return str(day) + s
+ s = when.strftime('%%d%s %%B %%Y' % (s))
+ if day < 10:
+ s = s[1:]
+ return s
def get(ctx, rtems_major_version):
global _version
@@ -122,19 +142,16 @@ def get(ctx, rtems_major_version):
#
# Get date and version from Git
#
- if ctx.exec_command(['git', 'diff-index', '--quiet', 'HEAD']) == 0:
+ if ctx.exec_command([ctx.env.GIT[0], 'diff-index', '--quiet', 'HEAD']) == 0:
modified = ''
else:
modified = '-modified'
- try:
- out = ctx.cmd_and_log(['git', 'log', '-1',
- '--format=%h,%cd', '--date=format:%e,%B,%Y'],
- quiet = True)
- f = out.strip('\n').split(',')
- version = version + '.' + f[0] + modified
- date = _pretty_day(int(f[1])) + ' ' + f[2] + ' ' + f[3]
- except waflib.Build.Errors.WafError:
- date = 'unknown date'
+ out = ctx.cmd_and_log([ctx.env.GIT[0], 'log', '-1',
+ '--format=%h,%cd', '--date=short'],
+ quiet = True)
+ f = out.strip('\n').split(',')
+ version = version + '.' + f[0] + modified
+ date = _pretty_day(ctx, f[1])
_version = version
_date = date
_release = released