diff options
Diffstat (limited to 'subcmds/version.py')
| -rw-r--r-- | subcmds/version.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/subcmds/version.py b/subcmds/version.py index 761172b7..09b053ea 100644 --- a/subcmds/version.py +++ b/subcmds/version.py | |||
| @@ -1,5 +1,3 @@ | |||
| 1 | # -*- coding:utf-8 -*- | ||
| 2 | # | ||
| 3 | # Copyright (C) 2009 The Android Open Source Project | 1 | # Copyright (C) 2009 The Android Open Source Project |
| 4 | # | 2 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| @@ -14,17 +12,20 @@ | |||
| 14 | # See the License for the specific language governing permissions and | 12 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. | 13 | # limitations under the License. |
| 16 | 14 | ||
| 17 | from __future__ import print_function | 15 | import platform |
| 18 | import sys | 16 | import sys |
| 17 | |||
| 19 | from command import Command, MirrorSafeCommand | 18 | from command import Command, MirrorSafeCommand |
| 20 | from git_command import git, RepoSourceVersion, user_agent | 19 | from git_command import git, RepoSourceVersion, user_agent |
| 21 | from git_refs import HEAD | 20 | from git_refs import HEAD |
| 21 | from wrapper import Wrapper | ||
| 22 | |||
| 22 | 23 | ||
| 23 | class Version(Command, MirrorSafeCommand): | 24 | class Version(Command, MirrorSafeCommand): |
| 24 | wrapper_version = None | 25 | wrapper_version = None |
| 25 | wrapper_path = None | 26 | wrapper_path = None |
| 26 | 27 | ||
| 27 | common = False | 28 | COMMON = False |
| 28 | helpSummary = "Display the version of repo" | 29 | helpSummary = "Display the version of repo" |
| 29 | helpUsage = """ | 30 | helpUsage = """ |
| 30 | %prog | 31 | %prog |
| @@ -33,16 +34,19 @@ class Version(Command, MirrorSafeCommand): | |||
| 33 | def Execute(self, opt, args): | 34 | def Execute(self, opt, args): |
| 34 | rp = self.manifest.repoProject | 35 | rp = self.manifest.repoProject |
| 35 | rem = rp.GetRemote(rp.remote.name) | 36 | rem = rp.GetRemote(rp.remote.name) |
| 37 | branch = rp.GetBranch('default') | ||
| 36 | 38 | ||
| 37 | # These might not be the same. Report them both. | 39 | # These might not be the same. Report them both. |
| 38 | src_ver = RepoSourceVersion() | 40 | src_ver = RepoSourceVersion() |
| 39 | rp_ver = rp.bare_git.describe(HEAD) | 41 | rp_ver = rp.bare_git.describe(HEAD) |
| 40 | print('repo version %s' % rp_ver) | 42 | print('repo version %s' % rp_ver) |
| 41 | print(' (from %s)' % rem.url) | 43 | print(' (from %s)' % rem.url) |
| 44 | print(' (tracking %s)' % branch.merge) | ||
| 45 | print(' (%s)' % rp.bare_git.log('-1', '--format=%cD', HEAD)) | ||
| 42 | 46 | ||
| 43 | if Version.wrapper_path is not None: | 47 | if self.wrapper_path is not None: |
| 44 | print('repo launcher version %s' % Version.wrapper_version) | 48 | print('repo launcher version %s' % self.wrapper_version) |
| 45 | print(' (from %s)' % Version.wrapper_path) | 49 | print(' (from %s)' % self.wrapper_path) |
| 46 | 50 | ||
| 47 | if src_ver != rp_ver: | 51 | if src_ver != rp_ver: |
| 48 | print(' (currently at %s)' % src_ver) | 52 | print(' (currently at %s)' % src_ver) |
| @@ -51,3 +55,12 @@ class Version(Command, MirrorSafeCommand): | |||
| 51 | print('git %s' % git.version_tuple().full) | 55 | print('git %s' % git.version_tuple().full) |
| 52 | print('git User-Agent %s' % user_agent.git) | 56 | print('git User-Agent %s' % user_agent.git) |
| 53 | print('Python %s' % sys.version) | 57 | print('Python %s' % sys.version) |
| 58 | uname = platform.uname() | ||
| 59 | if sys.version_info.major < 3: | ||
| 60 | # Python 3 returns a named tuple, but Python 2 is simpler. | ||
| 61 | print(uname) | ||
| 62 | else: | ||
| 63 | print('OS %s %s (%s)' % (uname.system, uname.release, uname.version)) | ||
| 64 | print('CPU %s (%s)' % | ||
| 65 | (uname.machine, uname.processor if uname.processor else 'unknown')) | ||
| 66 | print('Bug reports:', Wrapper().BUG_URL) | ||
