Mike Frysinger | f601376 | 2019-06-13 02:30:51 -0400 | [diff] [blame] | 1 | # -*- coding:utf-8 -*- |
Shawn O. Pearce | 47c1a63 | 2009-03-02 18:24:23 -0800 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2009 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 17 | from __future__ import print_function |
Mike Frysinger | 5f11eac | 2020-02-25 15:09:01 -0500 | [diff] [blame] | 18 | |
| 19 | import platform |
Shawn O. Pearce | 47c1a63 | 2009-03-02 18:24:23 -0800 | [diff] [blame] | 20 | import sys |
Mike Frysinger | 5f11eac | 2020-02-25 15:09:01 -0500 | [diff] [blame] | 21 | |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 22 | from command import Command, MirrorSafeCommand |
Mike Frysinger | 9bfdfbe | 2019-09-30 22:46:45 -0400 | [diff] [blame] | 23 | from git_command import git, RepoSourceVersion, user_agent |
David Pursehouse | e00aa6b | 2012-09-11 14:33:51 +0900 | [diff] [blame] | 24 | from git_refs import HEAD |
Shawn O. Pearce | 47c1a63 | 2009-03-02 18:24:23 -0800 | [diff] [blame] | 25 | |
David Pursehouse | 819827a | 2020-02-12 15:20:19 +0900 | [diff] [blame] | 26 | |
Shawn O. Pearce | c95583b | 2009-03-03 17:47:06 -0800 | [diff] [blame] | 27 | class Version(Command, MirrorSafeCommand): |
Shawn O. Pearce | ecff4f1 | 2011-11-29 15:01:33 -0800 | [diff] [blame] | 28 | wrapper_version = None |
| 29 | wrapper_path = None |
| 30 | |
Shawn O. Pearce | 47c1a63 | 2009-03-02 18:24:23 -0800 | [diff] [blame] | 31 | common = False |
| 32 | helpSummary = "Display the version of repo" |
| 33 | helpUsage = """ |
| 34 | %prog |
| 35 | """ |
| 36 | |
| 37 | def Execute(self, opt, args): |
| 38 | rp = self.manifest.repoProject |
| 39 | rem = rp.GetRemote(rp.remote.name) |
| 40 | |
Mike Frysinger | 9bfdfbe | 2019-09-30 22:46:45 -0400 | [diff] [blame] | 41 | # These might not be the same. Report them both. |
| 42 | src_ver = RepoSourceVersion() |
| 43 | rp_ver = rp.bare_git.describe(HEAD) |
| 44 | print('repo version %s' % rp_ver) |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 45 | print(' (from %s)' % rem.url) |
Shawn O. Pearce | ecff4f1 | 2011-11-29 15:01:33 -0800 | [diff] [blame] | 46 | |
Mike Frysinger | bb93046 | 2020-02-25 15:18:31 -0500 | [diff] [blame] | 47 | if self.wrapper_path is not None: |
| 48 | print('repo launcher version %s' % self.wrapper_version) |
| 49 | print(' (from %s)' % self.wrapper_path) |
Shawn O. Pearce | ecff4f1 | 2011-11-29 15:01:33 -0800 | [diff] [blame] | 50 | |
Mike Frysinger | 9bfdfbe | 2019-09-30 22:46:45 -0400 | [diff] [blame] | 51 | if src_ver != rp_ver: |
| 52 | print(' (currently at %s)' % src_ver) |
| 53 | |
| 54 | print('repo User-Agent %s' % user_agent.repo) |
Mike Frysinger | ca540ae | 2019-07-10 15:42:30 -0400 | [diff] [blame] | 55 | print('git %s' % git.version_tuple().full) |
Mike Frysinger | 9bfdfbe | 2019-09-30 22:46:45 -0400 | [diff] [blame] | 56 | print('git User-Agent %s' % user_agent.git) |
Sarah Owens | cecd1d8 | 2012-11-01 22:59:27 -0700 | [diff] [blame] | 57 | print('Python %s' % sys.version) |
Mike Frysinger | 5f11eac | 2020-02-25 15:09:01 -0500 | [diff] [blame] | 58 | uname = platform.uname() |
| 59 | print('OS %s %s (%s)' % (uname.system, uname.release, uname.version)) |
| 60 | print('CPU %s (%s)' % |
| 61 | (uname.machine, uname.processor if uname.processor else 'unknown')) |