blob: c68cb0afba201b6a7f039d803b76f8a97d47c367 [file] [log] [blame]
Shawn O. Pearce47c1a632009-03-02 18:24:23 -08001# Copyright (C) 2009 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Mike Frysinger5f11eac2020-02-25 15:09:01 -050015import platform
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080016import sys
Mike Frysinger5f11eac2020-02-25 15:09:01 -050017
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080018from command import Command, MirrorSafeCommand
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040019from git_command import git, RepoSourceVersion, user_agent
David Pursehousee00aa6b2012-09-11 14:33:51 +090020from git_refs import HEAD
Mike Frysingera1cd7702021-04-20 23:38:04 -040021from wrapper import Wrapper
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080022
David Pursehouse819827a2020-02-12 15:20:19 +090023
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080024class Version(Command, MirrorSafeCommand):
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080025 wrapper_version = None
26 wrapper_path = None
27
Mike Frysinger4f210542021-06-14 16:05:19 -040028 COMMON = False
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080029 helpSummary = "Display the version of repo"
30 helpUsage = """
31%prog
32"""
33
34 def Execute(self, opt, args):
35 rp = self.manifest.repoProject
Mike Frysingerdede5642022-07-10 04:56:04 -040036 rem = rp.GetRemote()
Mike Frysinger0588f3d2021-01-08 13:50:23 -050037 branch = rp.GetBranch('default')
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080038
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040039 # These might not be the same. Report them both.
40 src_ver = RepoSourceVersion()
41 rp_ver = rp.bare_git.describe(HEAD)
42 print('repo version %s' % rp_ver)
Sarah Owenscecd1d82012-11-01 22:59:27 -070043 print(' (from %s)' % rem.url)
Mike Frysinger0588f3d2021-01-08 13:50:23 -050044 print(' (tracking %s)' % branch.merge)
Mike Frysingerb4a6f6d2020-03-30 18:51:19 -040045 print(' (%s)' % rp.bare_git.log('-1', '--format=%cD', HEAD))
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080046
Mike Frysingerbb930462020-02-25 15:18:31 -050047 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. Pearceecff4f12011-11-29 15:01:33 -080050
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040051 if src_ver != rp_ver:
52 print(' (currently at %s)' % src_ver)
53
54 print('repo User-Agent %s' % user_agent.repo)
Mike Frysingerca540ae2019-07-10 15:42:30 -040055 print('git %s' % git.version_tuple().full)
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040056 print('git User-Agent %s' % user_agent.git)
Sarah Owenscecd1d82012-11-01 22:59:27 -070057 print('Python %s' % sys.version)
Mike Frysinger5f11eac2020-02-25 15:09:01 -050058 uname = platform.uname()
Mike Frysingere257d562020-03-23 16:55:02 -040059 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'))
Mike Frysingera1cd7702021-04-20 23:38:04 -040066 print('Bug reports:', Wrapper().BUG_URL)