diff options
author | Shawn O. Pearce <sop@google.com> | 2009-03-02 18:24:23 -0800 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-03-02 18:24:23 -0800 |
commit | 47c1a63a07ebd67efac00ca9e0d877633aea5881 (patch) | |
tree | 1d52cf3c114a4389a0ec79102604aa8ca6afdde7 | |
parent | 559b846b17a5b720c1247d07e292150466f27f96 (diff) | |
download | git-repo-47c1a63a07ebd67efac00ca9e0d877633aea5881.tar.gz |
Add 'repo version' to describe what code we are running
I meant to have this in here, so clients can more easily report
what version of repo they are running.
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rwxr-xr-x | main.py | 10 | ||||
-rw-r--r-- | subcmds/version.py | 35 |
2 files changed, 45 insertions, 0 deletions
@@ -46,6 +46,9 @@ global_options.add_option('-p', '--paginate', | |||
46 | global_options.add_option('--no-pager', | 46 | global_options.add_option('--no-pager', |
47 | dest='no_pager', action='store_true', | 47 | dest='no_pager', action='store_true', |
48 | help='disable the pager') | 48 | help='disable the pager') |
49 | global_options.add_option('--version', | ||
50 | dest='show_version', action='store_true', | ||
51 | help='display this version of repo') | ||
49 | 52 | ||
50 | class _Repo(object): | 53 | class _Repo(object): |
51 | def __init__(self, repodir): | 54 | def __init__(self, repodir): |
@@ -69,6 +72,13 @@ class _Repo(object): | |||
69 | argv = [] | 72 | argv = [] |
70 | gopts, gargs = global_options.parse_args(glob) | 73 | gopts, gargs = global_options.parse_args(glob) |
71 | 74 | ||
75 | if gopts.show_version: | ||
76 | if name == 'help': | ||
77 | name = 'version' | ||
78 | else: | ||
79 | print >>sys.stderr, 'fatal: invalid usage of --version' | ||
80 | sys.exit(1) | ||
81 | |||
72 | try: | 82 | try: |
73 | cmd = self.commands[name] | 83 | cmd = self.commands[name] |
74 | except KeyError: | 84 | except KeyError: |
diff --git a/subcmds/version.py b/subcmds/version.py new file mode 100644 index 00000000..4f19a0ca --- /dev/null +++ b/subcmds/version.py | |||
@@ -0,0 +1,35 @@ | |||
1 | # | ||
2 | # Copyright (C) 2009 The Android Open Source Project | ||
3 | # | ||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | # you may not use this file except in compliance with the License. | ||
6 | # You may obtain a copy of the License at | ||
7 | # | ||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | # | ||
10 | # Unless required by applicable law or agreed to in writing, software | ||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | # See the License for the specific language governing permissions and | ||
14 | # limitations under the License. | ||
15 | |||
16 | import sys | ||
17 | from command import Command | ||
18 | from git_command import git | ||
19 | from project import HEAD | ||
20 | |||
21 | class Version(Command): | ||
22 | common = False | ||
23 | helpSummary = "Display the version of repo" | ||
24 | helpUsage = """ | ||
25 | %prog | ||
26 | """ | ||
27 | |||
28 | def Execute(self, opt, args): | ||
29 | rp = self.manifest.repoProject | ||
30 | rem = rp.GetRemote(rp.remote.name) | ||
31 | |||
32 | print 'repo version %s' % rp.work_git.describe(HEAD) | ||
33 | print ' (from %s)' % rem.url | ||
34 | print git.version().strip() | ||
35 | print 'Python %s' % sys.version | ||