From cf411b3f03c3bd6001701136be5a874a85f1dc91 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Tue, 3 Dec 2024 21:29:01 +0000 Subject: [PATCH] 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 Commit-Queue: Josip Sokcevic Tested-by: Josip Sokcevic --- command.py | 4 -- error.py | 4 -- main.py | 5 --- project.py | 3 -- repo | 88 +++++--------------------------------- tests/fixtures/gitc_config | 1 - tests/test_wrapper.py | 75 +------------------------------- 7 files changed, 12 insertions(+), 168 deletions(-) delete mode 100644 tests/fixtures/gitc_config diff --git a/command.py b/command.py index 22115ac2..c32a095c 100644 --- a/command.py +++ b/command.py @@ -547,7 +547,3 @@ class MirrorSafeCommand: """Command permits itself to run within a mirror, and does not require a working directory. """ - - -class GitcClientCommand: - """Command that requires the local client to be a GITC client.""" diff --git a/error.py b/error.py index 36bc2129..1a65f365 100644 --- a/error.py +++ b/error.py @@ -111,10 +111,6 @@ class GitAuthError(RepoExitError): """Cannot talk to remote due to auth issue.""" -class GitcUnsupportedError(RepoExitError): - """Gitc no longer supported.""" - - class UploadError(RepoError): """A bundle upload to Gerrit did not succeed.""" diff --git a/main.py b/main.py index 9f415e38..707b74ad 100755 --- a/main.py +++ b/main.py @@ -45,7 +45,6 @@ from command import InteractiveCommand from command import MirrorSafeCommand from editor import Editor from error import DownloadError -from error import GitcUnsupportedError from error import InvalidProjectGroupsError from error import ManifestInvalidRevisionError from error import ManifestParseError @@ -308,10 +307,6 @@ class _Repo: outer_client=outer_client, ) - if Wrapper().gitc_parse_clientdir(os.getcwd()): - logger.error("GITC is not supported.") - raise GitcUnsupportedError() - try: cmd = self.commands[name]( repodir=self.repodir, diff --git a/project.py b/project.py index 9a7681e0..8fec9816 100644 --- a/project.py +++ b/project.py @@ -576,7 +576,6 @@ class Project: dest_branch=None, optimized_fetch=False, retry_fetches=0, - old_revision=None, ): """Init a Project object. @@ -609,7 +608,6 @@ class Project: only fetch from the remote if the sha1 is not present locally. retry_fetches: Retry remote fetches n times upon receiving transient error with exponential backoff and jitter. - old_revision: saved git commit id for open GITC projects. """ self.client = self.manifest = manifest self.name = name @@ -639,7 +637,6 @@ class Project: self.linkfiles = [] self.annotations = [] self.dest_branch = dest_branch - self.old_revision = old_revision # This will be filled in if a project is later identified to be the # project containing repo hooks. diff --git a/repo b/repo index 6cda1366..85825e80 100755 --- a/repo +++ b/repo @@ -215,8 +215,6 @@ repodir = ".repo" # name of repo's private directory S_repo = "repo" # special repo repository S_manifests = "manifests" # special manifest repository REPO_MAIN = S_repo + "/main.py" # main script -GITC_CONFIG_FILE = "/gitc/.config" -GITC_FS_ROOT_DIR = "/gitc/manifest-rw/" import collections @@ -235,12 +233,9 @@ home_dot_repo = os.path.join(repo_config_dir, ".repoconfig") gpg_dir = os.path.join(home_dot_repo, "gnupg") -def GetParser(gitc_init=False): +def GetParser(): """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) InitParser(parser) @@ -557,49 +552,6 @@ def run_command(cmd, **kwargs): 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.*)", 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): """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) -def _Init(args, gitc_init=False): +def _Init(args): """Installs repo by cloning it over the network.""" - parser = GetParser(gitc_init=gitc_init) + parser = GetParser() opt, args = parser.parse_args(args) if args: if not opt.manifest_url: @@ -1164,7 +1116,7 @@ class _Options: def _ExpandAlias(name): """Look up user registered aliases.""" # 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, [] alias = _GetRepoConfig(f"alias.{name}") @@ -1292,10 +1244,6 @@ class Requirements: def _Usage(): - gitc_usage = "" - if get_gitc_manifest_dir(): - gitc_usage = " gitc-init Initialize a GITC Client.\n" - print( """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: init Install repo in the current working directory -""" - + gitc_usage - + """ help Display detailed help on a command + help Display detailed help on a command 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): if args: - if args[0] in {"init", "gitc-init"}: - parser = GetParser(gitc_init=args[0] == "gitc-init") + if args[0] in {"init"}: + parser = GetParser() parser.print_help() sys.exit(0) else: @@ -1407,23 +1353,11 @@ def main(orig_args): # We run this early as we run some git commands ourselves. 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__) 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: # Only expand aliases here since we'll be parsing the CLI ourselves. # If we had repo_main, alias expansion would happen in main.py. @@ -1438,11 +1372,11 @@ def main(orig_args): _Version() if not cmd: _NotInstalled() - if cmd == "init" or cmd == "gitc-init": + if cmd == "init": if my_git: _SetDefaultsTo(my_git) try: - _Init(args, gitc_init=(cmd == "gitc-init")) + _Init(args) except CloneFailure: path = os.path.join(repodir, S_repo) print( diff --git a/tests/fixtures/gitc_config b/tests/fixtures/gitc_config deleted file mode 100644 index a7f3d1c9..00000000 --- a/tests/fixtures/gitc_config +++ /dev/null @@ -1 +0,0 @@ -gitc_dir=/test/usr/local/google/gitc diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index ea7a8b4d..8bebdf80 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -72,84 +72,11 @@ class RepoWrapperUnitTest(RepoWrapperTestCase): def test_init_parser(self): """Make sure 'init' GetParser works.""" - parser = self.wrapper.GetParser(gitc_init=False) + parser = self.wrapper.GetParser() opts, args = parser.parse_args([]) self.assertEqual([], args) 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): """Check SetGitTrace2ParentSid behavior."""