blob: 8721bf49d2a6399efb9b26b80a5fd4436cacf0f5 [file] [log] [blame]
Mike Frysingerf6013762019-06-13 02:30:51 -04001# -*- coding:utf-8 -*-
Shawn O. Pearce47c1a632009-03-02 18:24:23 -08002#
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 Owenscecd1d82012-11-01 22:59:27 -070017from __future__ import print_function
Mike Frysinger5f11eac2020-02-25 15:09:01 -050018
19import platform
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080020import sys
Mike Frysinger5f11eac2020-02-25 15:09:01 -050021
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080022from command import Command, MirrorSafeCommand
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040023from git_command import git, RepoSourceVersion, user_agent
David Pursehousee00aa6b2012-09-11 14:33:51 +090024from git_refs import HEAD
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080025
David Pursehouse819827a2020-02-12 15:20:19 +090026
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080027class Version(Command, MirrorSafeCommand):
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080028 wrapper_version = None
29 wrapper_path = None
30
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080031 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 Frysinger9bfdfbe2019-09-30 22:46:45 -040041 # 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 Owenscecd1d82012-11-01 22:59:27 -070045 print(' (from %s)' % rem.url)
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()
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'))