mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Add GitcClientCommand class for GITC-specific commands
These won't show up as common commands in the help text unless in a GITC client, and will refuse to execute. Change-Id: Iffe82adcc9d6ddde9cb4b204f83ff018042bdab0
This commit is contained in:
parent
7b01b2fd01
commit
79360640f4
@ -231,7 +231,12 @@ class MirrorSafeCommand(object):
|
|||||||
and does not require a working directory.
|
and does not require a working directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class RequiresGitcCommand(object):
|
class GitcAvailableCommand(object):
|
||||||
"""Command that requires GITC to be available, but does
|
"""Command that requires GITC to be available, but does
|
||||||
not require the local client to be a GITC client.
|
not require the local client to be a GITC client.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
class GitcClientCommand(object):
|
||||||
|
"""Command that requires the local client to be a GITC
|
||||||
|
client.
|
||||||
|
"""
|
||||||
|
9
main.py
9
main.py
@ -42,7 +42,7 @@ from git_command import git, GitCommand
|
|||||||
from git_config import init_ssh, close_ssh
|
from git_config import init_ssh, close_ssh
|
||||||
from command import InteractiveCommand
|
from command import InteractiveCommand
|
||||||
from command import MirrorSafeCommand
|
from command import MirrorSafeCommand
|
||||||
from command import RequiresGitcCommand
|
from command import GitcAvailableCommand, GitcClientCommand
|
||||||
from subcmds.version import Version
|
from subcmds.version import Version
|
||||||
from editor import Editor
|
from editor import Editor
|
||||||
from error import DownloadError
|
from error import DownloadError
|
||||||
@ -144,11 +144,16 @@ class _Repo(object):
|
|||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if isinstance(cmd, RequiresGitcCommand) and not gitc_utils.get_gitc_manifest_dir():
|
if isinstance(cmd, GitcAvailableCommand) and not gitc_utils.get_gitc_manifest_dir():
|
||||||
print("fatal: '%s' requires GITC to be available" % name,
|
print("fatal: '%s' requires GITC to be available" % name,
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if isinstance(cmd, GitcClientCommand) and not gitc_client_name:
|
||||||
|
print("fatal: '%s' requires a GITC client" % name,
|
||||||
|
file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
copts, cargs = cmd.OptionParser.parse_args(argv)
|
copts, cargs = cmd.OptionParser.parse_args(argv)
|
||||||
copts = cmd.ReadEnvironmentOptions(copts)
|
copts = cmd.ReadEnvironmentOptions(copts)
|
||||||
|
@ -18,12 +18,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import gitc_utils
|
import gitc_utils
|
||||||
from command import RequiresGitcCommand
|
from command import GitcAvailableCommand
|
||||||
from manifest_xml import GitcManifest
|
from manifest_xml import GitcManifest
|
||||||
from subcmds import init
|
from subcmds import init
|
||||||
|
|
||||||
|
|
||||||
class GitcInit(init.Init, RequiresGitcCommand):
|
class GitcInit(init.Init, GitcAvailableCommand):
|
||||||
common = True
|
common = True
|
||||||
helpSummary = "Initialize a GITC Client."
|
helpSummary = "Initialize a GITC Client."
|
||||||
helpUsage = """
|
helpUsage = """
|
||||||
|
@ -19,7 +19,7 @@ import sys
|
|||||||
from formatter import AbstractFormatter, DumbWriter
|
from formatter import AbstractFormatter, DumbWriter
|
||||||
|
|
||||||
from color import Coloring
|
from color import Coloring
|
||||||
from command import PagedCommand, MirrorSafeCommand, RequiresGitcCommand
|
from command import PagedCommand, MirrorSafeCommand, GitcAvailableCommand, GitcClientCommand
|
||||||
import gitc_utils
|
import gitc_utils
|
||||||
|
|
||||||
class Help(PagedCommand, MirrorSafeCommand):
|
class Help(PagedCommand, MirrorSafeCommand):
|
||||||
@ -57,8 +57,12 @@ Displays detailed usage information about a command.
|
|||||||
print('The most commonly used repo commands are:')
|
print('The most commonly used repo commands are:')
|
||||||
|
|
||||||
def gitc_supported(cmd):
|
def gitc_supported(cmd):
|
||||||
if not isinstance(cmd, RequiresGitcCommand):
|
if not isinstance(cmd, GitcAvailableCommand) and not isinstance(cmd, GitcClientCommand):
|
||||||
return True
|
return True
|
||||||
|
if self.manifest.isGitcClient:
|
||||||
|
return True
|
||||||
|
if isinstance(cmd, GitcClientCommand):
|
||||||
|
return False
|
||||||
if gitc_utils.get_gitc_manifest_dir():
|
if gitc_utils.get_gitc_manifest_dir():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user