Remove gitc support from repo

gitc is no longer available.

Change-Id: I0cbfdf936832f2cdd4876104ae3cc5a6e26154e2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/444841
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Tested-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
Josip Sokcevic 2024-12-03 21:29:01 +00:00 committed by LUCI
parent 1feecbd91e
commit cf411b3f03
7 changed files with 12 additions and 168 deletions

View File

@ -547,7 +547,3 @@ class MirrorSafeCommand:
"""Command permits itself to run within a mirror, and does not require a """Command permits itself to run within a mirror, and does not require a
working directory. working directory.
""" """
class GitcClientCommand:
"""Command that requires the local client to be a GITC client."""

View File

@ -111,10 +111,6 @@ class GitAuthError(RepoExitError):
"""Cannot talk to remote due to auth issue.""" """Cannot talk to remote due to auth issue."""
class GitcUnsupportedError(RepoExitError):
"""Gitc no longer supported."""
class UploadError(RepoError): class UploadError(RepoError):
"""A bundle upload to Gerrit did not succeed.""" """A bundle upload to Gerrit did not succeed."""

View File

@ -45,7 +45,6 @@ from command import InteractiveCommand
from command import MirrorSafeCommand from command import MirrorSafeCommand
from editor import Editor from editor import Editor
from error import DownloadError from error import DownloadError
from error import GitcUnsupportedError
from error import InvalidProjectGroupsError from error import InvalidProjectGroupsError
from error import ManifestInvalidRevisionError from error import ManifestInvalidRevisionError
from error import ManifestParseError from error import ManifestParseError
@ -308,10 +307,6 @@ class _Repo:
outer_client=outer_client, outer_client=outer_client,
) )
if Wrapper().gitc_parse_clientdir(os.getcwd()):
logger.error("GITC is not supported.")
raise GitcUnsupportedError()
try: try:
cmd = self.commands[name]( cmd = self.commands[name](
repodir=self.repodir, repodir=self.repodir,

View File

@ -576,7 +576,6 @@ class Project:
dest_branch=None, dest_branch=None,
optimized_fetch=False, optimized_fetch=False,
retry_fetches=0, retry_fetches=0,
old_revision=None,
): ):
"""Init a Project object. """Init a Project object.
@ -609,7 +608,6 @@ class Project:
only fetch from the remote if the sha1 is not present locally. only fetch from the remote if the sha1 is not present locally.
retry_fetches: Retry remote fetches n times upon receiving transient retry_fetches: Retry remote fetches n times upon receiving transient
error with exponential backoff and jitter. error with exponential backoff and jitter.
old_revision: saved git commit id for open GITC projects.
""" """
self.client = self.manifest = manifest self.client = self.manifest = manifest
self.name = name self.name = name
@ -639,7 +637,6 @@ class Project:
self.linkfiles = [] self.linkfiles = []
self.annotations = [] self.annotations = []
self.dest_branch = dest_branch self.dest_branch = dest_branch
self.old_revision = old_revision
# This will be filled in if a project is later identified to be the # This will be filled in if a project is later identified to be the
# project containing repo hooks. # project containing repo hooks.

84
repo
View File

@ -215,8 +215,6 @@ repodir = ".repo" # name of repo's private directory
S_repo = "repo" # special repo repository S_repo = "repo" # special repo repository
S_manifests = "manifests" # special manifest repository S_manifests = "manifests" # special manifest repository
REPO_MAIN = S_repo + "/main.py" # main script REPO_MAIN = S_repo + "/main.py" # main script
GITC_CONFIG_FILE = "/gitc/.config"
GITC_FS_ROOT_DIR = "/gitc/manifest-rw/"
import collections import collections
@ -235,11 +233,8 @@ home_dot_repo = os.path.join(repo_config_dir, ".repoconfig")
gpg_dir = os.path.join(home_dot_repo, "gnupg") gpg_dir = os.path.join(home_dot_repo, "gnupg")
def GetParser(gitc_init=False): def GetParser():
"""Setup the CLI parser.""" """Setup the CLI parser."""
if gitc_init:
sys.exit("repo: fatal: GITC not supported.")
else:
usage = "repo init [options] [-u] url" usage = "repo init [options] [-u] url"
parser = optparse.OptionParser(usage=usage) parser = optparse.OptionParser(usage=usage)
@ -557,49 +552,6 @@ def run_command(cmd, **kwargs):
return ret return ret
_gitc_manifest_dir = None
def get_gitc_manifest_dir():
global _gitc_manifest_dir
if _gitc_manifest_dir is None:
_gitc_manifest_dir = ""
try:
with open(GITC_CONFIG_FILE) as gitc_config:
for line in gitc_config:
match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line)
if match:
_gitc_manifest_dir = match.group("gitc_manifest_dir")
except OSError:
pass
return _gitc_manifest_dir
def gitc_parse_clientdir(gitc_fs_path):
"""Parse a path in the GITC FS and return its client name.
Args:
gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR.
Returns:
The GITC client name.
"""
if gitc_fs_path == GITC_FS_ROOT_DIR:
return None
if not gitc_fs_path.startswith(GITC_FS_ROOT_DIR):
manifest_dir = get_gitc_manifest_dir()
if manifest_dir == "":
return None
if manifest_dir[-1] != "/":
manifest_dir += "/"
if gitc_fs_path == manifest_dir:
return None
if not gitc_fs_path.startswith(manifest_dir):
return None
return gitc_fs_path.split(manifest_dir)[1].split("/")[0]
return gitc_fs_path.split(GITC_FS_ROOT_DIR)[1].split("/")[0]
class CloneFailure(Exception): class CloneFailure(Exception):
"""Indicate the remote clone of repo itself failed.""" """Indicate the remote clone of repo itself failed."""
@ -638,9 +590,9 @@ def check_repo_rev(dst, rev, repo_verify=True, quiet=False):
return (remote_ref, rev) return (remote_ref, rev)
def _Init(args, gitc_init=False): def _Init(args):
"""Installs repo by cloning it over the network.""" """Installs repo by cloning it over the network."""
parser = GetParser(gitc_init=gitc_init) parser = GetParser()
opt, args = parser.parse_args(args) opt, args = parser.parse_args(args)
if args: if args:
if not opt.manifest_url: if not opt.manifest_url:
@ -1164,7 +1116,7 @@ class _Options:
def _ExpandAlias(name): def _ExpandAlias(name):
"""Look up user registered aliases.""" """Look up user registered aliases."""
# We don't resolve aliases for existing subcommands. This matches git. # We don't resolve aliases for existing subcommands. This matches git.
if name in {"gitc-init", "help", "init"}: if name in {"help", "init"}:
return name, [] return name, []
alias = _GetRepoConfig(f"alias.{name}") alias = _GetRepoConfig(f"alias.{name}")
@ -1292,10 +1244,6 @@ class Requirements:
def _Usage(): def _Usage():
gitc_usage = ""
if get_gitc_manifest_dir():
gitc_usage = " gitc-init Initialize a GITC Client.\n"
print( print(
"""usage: repo COMMAND [ARGS] """usage: repo COMMAND [ARGS]
@ -1304,9 +1252,7 @@ repo is not yet installed. Use "repo init" to install it here.
The most commonly used repo commands are: The most commonly used repo commands are:
init Install repo in the current working directory init Install repo in the current working directory
""" help Display detailed help on a command
+ gitc_usage
+ """ help Display detailed help on a command
For access to the full online help, install repo ("repo init"). For access to the full online help, install repo ("repo init").
""" """
@ -1317,8 +1263,8 @@ For access to the full online help, install repo ("repo init").
def _Help(args): def _Help(args):
if args: if args:
if args[0] in {"init", "gitc-init"}: if args[0] in {"init"}:
parser = GetParser(gitc_init=args[0] == "gitc-init") parser = GetParser()
parser.print_help() parser.print_help()
sys.exit(0) sys.exit(0)
else: else:
@ -1407,23 +1353,11 @@ def main(orig_args):
# We run this early as we run some git commands ourselves. # We run this early as we run some git commands ourselves.
SetGitTrace2ParentSid() SetGitTrace2ParentSid()
repo_main, rel_repo_dir = None, None
# Don't use the local repo copy, make sure to switch to the gitc client first.
if cmd != "gitc-init":
repo_main, rel_repo_dir = _FindRepo() repo_main, rel_repo_dir = _FindRepo()
wrapper_path = os.path.abspath(__file__) wrapper_path = os.path.abspath(__file__)
my_main, my_git = _RunSelf(wrapper_path) my_main, my_git = _RunSelf(wrapper_path)
cwd = os.getcwd()
if get_gitc_manifest_dir() and cwd.startswith(get_gitc_manifest_dir()):
print(
"error: repo cannot be used in the GITC local manifest directory."
"\nIf you want to work on this GITC client please rerun this "
"command from the corresponding client under /gitc/",
file=sys.stderr,
)
sys.exit(1)
if not repo_main: if not repo_main:
# Only expand aliases here since we'll be parsing the CLI ourselves. # Only expand aliases here since we'll be parsing the CLI ourselves.
# If we had repo_main, alias expansion would happen in main.py. # If we had repo_main, alias expansion would happen in main.py.
@ -1438,11 +1372,11 @@ def main(orig_args):
_Version() _Version()
if not cmd: if not cmd:
_NotInstalled() _NotInstalled()
if cmd == "init" or cmd == "gitc-init": if cmd == "init":
if my_git: if my_git:
_SetDefaultsTo(my_git) _SetDefaultsTo(my_git)
try: try:
_Init(args, gitc_init=(cmd == "gitc-init")) _Init(args)
except CloneFailure: except CloneFailure:
path = os.path.join(repodir, S_repo) path = os.path.join(repodir, S_repo)
print( print(

View File

@ -1 +0,0 @@
gitc_dir=/test/usr/local/google/gitc

View File

@ -72,84 +72,11 @@ class RepoWrapperUnitTest(RepoWrapperTestCase):
def test_init_parser(self): def test_init_parser(self):
"""Make sure 'init' GetParser works.""" """Make sure 'init' GetParser works."""
parser = self.wrapper.GetParser(gitc_init=False) parser = self.wrapper.GetParser()
opts, args = parser.parse_args([]) opts, args = parser.parse_args([])
self.assertEqual([], args) self.assertEqual([], args)
self.assertIsNone(opts.manifest_url) self.assertIsNone(opts.manifest_url)
def test_gitc_init_parser(self):
"""Make sure 'gitc-init' GetParser raises."""
with self.assertRaises(SystemExit):
self.wrapper.GetParser(gitc_init=True)
def test_get_gitc_manifest_dir_no_gitc(self):
"""
Test reading a missing gitc config file
"""
self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config")
val = self.wrapper.get_gitc_manifest_dir()
self.assertEqual(val, "")
def test_get_gitc_manifest_dir(self):
"""
Test reading the gitc config file and parsing the directory
"""
self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config")
val = self.wrapper.get_gitc_manifest_dir()
self.assertEqual(val, "/test/usr/local/google/gitc")
def test_gitc_parse_clientdir_no_gitc(self):
"""
Test parsing the gitc clientdir without gitc running
"""
self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config")
self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test"
)
def test_gitc_parse_clientdir(self):
"""
Test parsing the gitc clientdir
"""
self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config")
self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test"
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/"), "test"
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/extra"),
"test",
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir(
"/test/usr/local/google/gitc/test"
),
"test",
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir(
"/test/usr/local/google/gitc/test/"
),
"test",
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir(
"/test/usr/local/google/gitc/test/extra"
),
"test",
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/"), None
)
self.assertEqual(
self.wrapper.gitc_parse_clientdir("/test/usr/local/google/gitc/"),
None,
)
class SetGitTrace2ParentSid(RepoWrapperTestCase): class SetGitTrace2ParentSid(RepoWrapperTestCase):
"""Check SetGitTrace2ParentSid behavior.""" """Check SetGitTrace2ParentSid behavior."""