blob: 9231654900d3da08d59e5785841da8e1357540bd [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
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
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080028 common = False
29 helpSummary = "Display the version of repo"
30 helpUsage = """
31%prog
32"""
33
34 def Execute(self, opt, args):
35 rp = self.manifest.repoProject
36 rem = rp.GetRemote(rp.remote.name)
37
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040038 # These might not be the same. Report them both.
39 src_ver = RepoSourceVersion()
40 rp_ver = rp.bare_git.describe(HEAD)
41 print('repo version %s' % rp_ver)
Sarah Owenscecd1d82012-11-01 22:59:27 -070042 print(' (from %s)' % rem.url)
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080043
44 if Version.wrapper_path is not None:
Sarah Owenscecd1d82012-11-01 22:59:27 -070045 print('repo launcher version %s' % Version.wrapper_version)
46 print(' (from %s)' % Version.wrapper_path)
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080047
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040048 if src_ver != rp_ver:
49 print(' (currently at %s)' % src_ver)
50
51 print('repo User-Agent %s' % user_agent.repo)
Mike Frysingerca540ae2019-07-10 15:42:30 -040052 print('git %s' % git.version_tuple().full)
Mike Frysinger9bfdfbe2019-09-30 22:46:45 -040053 print('git User-Agent %s' % user_agent.git)
Sarah Owenscecd1d82012-11-01 22:59:27 -070054 print('Python %s' % sys.version)