blob: 761172b761fba20400ad91825f6396d9bf6234be [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
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080018import sys
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080019from command import Command, MirrorSafeCommand
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040020from git_command import git, RepoSourceVersion, user_agent
David Pursehousee00aa6b2012-09-11 14:33:51 +090021from git_refs import HEAD
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080022
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080023class Version(Command, MirrorSafeCommand):
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080024 wrapper_version = None
25 wrapper_path = None
26
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080027 common = False
28 helpSummary = "Display the version of repo"
29 helpUsage = """
30%prog
31"""
32
33 def Execute(self, opt, args):
34 rp = self.manifest.repoProject
35 rem = rp.GetRemote(rp.remote.name)
36
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040037 # These might not be the same. Report them both.
38 src_ver = RepoSourceVersion()
39 rp_ver = rp.bare_git.describe(HEAD)
40 print('repo version %s' % rp_ver)
Sarah Owenscecd1d82012-11-01 22:59:27 -070041 print(' (from %s)' % rem.url)
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080042
43 if Version.wrapper_path is not None:
Sarah Owenscecd1d82012-11-01 22:59:27 -070044 print('repo launcher version %s' % Version.wrapper_version)
45 print(' (from %s)' % Version.wrapper_path)
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080046
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040047 if src_ver != rp_ver:
48 print(' (currently at %s)' % src_ver)
49
50 print('repo User-Agent %s' % user_agent.repo)
Mike Frysingerca540ae2019-07-10 15:42:30 -040051 print('git %s' % git.version_tuple().full)
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040052 print('git User-Agent %s' % user_agent.git)
Sarah Owenscecd1d82012-11-01 22:59:27 -070053 print('Python %s' % sys.version)