version: fix running under Python 2

This gets the unittests passing again for now.

Change-Id: Ibed430a305bc26b907ad0ea424c7eec7de37e942
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259994
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
Mike Frysinger 2020-03-23 16:55:02 -04:00
parent 3599cc3975
commit e257d56665
2 changed files with 14 additions and 6 deletions

10
repo
View File

@ -1060,9 +1060,13 @@ def _Version():
print('git %s' % (ParseGitVersion().full,)) print('git %s' % (ParseGitVersion().full,))
print('Python %s' % sys.version) print('Python %s' % sys.version)
uname = platform.uname() uname = platform.uname()
print('OS %s %s (%s)' % (uname.system, uname.release, uname.version)) if sys.version_info.major < 3:
print('CPU %s (%s)' % # Python 3 returns a named tuple, but Python 2 is simpler.
(uname.machine, uname.processor if uname.processor else 'unknown')) print(uname)
else:
print('OS %s %s (%s)' % (uname.system, uname.release, uname.version))
print('CPU %s (%s)' %
(uname.machine, uname.processor if uname.processor else 'unknown'))
sys.exit(0) sys.exit(0)

View File

@ -56,6 +56,10 @@ class Version(Command, MirrorSafeCommand):
print('git User-Agent %s' % user_agent.git) print('git User-Agent %s' % user_agent.git)
print('Python %s' % sys.version) print('Python %s' % sys.version)
uname = platform.uname() uname = platform.uname()
print('OS %s %s (%s)' % (uname.system, uname.release, uname.version)) if sys.version_info.major < 3:
print('CPU %s (%s)' % # Python 3 returns a named tuple, but Python 2 is simpler.
(uname.machine, uname.processor if uname.processor else 'unknown')) print(uname)
else:
print('OS %s %s (%s)' % (uname.system, uname.release, uname.version))
print('CPU %s (%s)' %
(uname.machine, uname.processor if uname.processor else 'unknown'))