mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-27 07:16:20 +00:00
c95583bf4f
If a client was created with "repo init --mirror" then there are no working directories present, and no files checked out. Using a command like "repo status" in this context makes no sense, and actually throws back a Pytyon traceback at the console when the underlying commands fail out. We now tag commands with the MirrorSafeCommand type if they are able to be executed within a mirror directory safely. Using a command in a mirror which lacks this base class results in a useful error letting you know the command isn't supported. Bug: REPO-14 Signed-off-by: Shawn O. Pearce <sop@google.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
#
|
|
# Copyright (C) 2009 The Android Open Source Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import sys
|
|
from command import Command, MirrorSafeCommand
|
|
from git_command import git
|
|
from project import HEAD
|
|
|
|
class Version(Command, MirrorSafeCommand):
|
|
common = False
|
|
helpSummary = "Display the version of repo"
|
|
helpUsage = """
|
|
%prog
|
|
"""
|
|
|
|
def Execute(self, opt, args):
|
|
rp = self.manifest.repoProject
|
|
rem = rp.GetRemote(rp.remote.name)
|
|
|
|
print 'repo version %s' % rp.work_git.describe(HEAD)
|
|
print ' (from %s)' % rem.url
|
|
print git.version().strip()
|
|
print 'Python %s' % sys.version
|