Skip to content

Commit cf411b3

Browse files
sokcevicGLUCI
authored andcommitted
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 <[email protected]> Commit-Queue: Josip Sokcevic <[email protected]> Tested-by: Josip Sokcevic <[email protected]>
1 parent 1feecbd commit cf411b3

File tree

7 files changed

+12
-168
lines changed

7 files changed

+12
-168
lines changed

command.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,3 @@ class MirrorSafeCommand:
547547
"""Command permits itself to run within a mirror, and does not require a
548548
working directory.
549549
"""
550-
551-
552-
class GitcClientCommand:
553-
"""Command that requires the local client to be a GITC client."""

error.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ class GitAuthError(RepoExitError):
111111
"""Cannot talk to remote due to auth issue."""
112112

113113

114-
class GitcUnsupportedError(RepoExitError):
115-
"""Gitc no longer supported."""
116-
117-
118114
class UploadError(RepoError):
119115
"""A bundle upload to Gerrit did not succeed."""
120116

main.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from command import MirrorSafeCommand
4646
from editor import Editor
4747
from error import DownloadError
48-
from error import GitcUnsupportedError
4948
from error import InvalidProjectGroupsError
5049
from error import ManifestInvalidRevisionError
5150
from error import ManifestParseError
@@ -308,10 +307,6 @@ def _RunLong(self, name, gopts, argv, git_trace2_event_log):
308307
outer_client=outer_client,
309308
)
310309

311-
if Wrapper().gitc_parse_clientdir(os.getcwd()):
312-
logger.error("GITC is not supported.")
313-
raise GitcUnsupportedError()
314-
315310
try:
316311
cmd = self.commands[name](
317312
repodir=self.repodir,

project.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ def __init__(
576576
dest_branch=None,
577577
optimized_fetch=False,
578578
retry_fetches=0,
579-
old_revision=None,
580579
):
581580
"""Init a Project object.
582581
@@ -609,7 +608,6 @@ def __init__(
609608
only fetch from the remote if the sha1 is not present locally.
610609
retry_fetches: Retry remote fetches n times upon receiving transient
611610
error with exponential backoff and jitter.
612-
old_revision: saved git commit id for open GITC projects.
613611
"""
614612
self.client = self.manifest = manifest
615613
self.name = name
@@ -639,7 +637,6 @@ def __init__(
639637
self.linkfiles = []
640638
self.annotations = []
641639
self.dest_branch = dest_branch
642-
self.old_revision = old_revision
643640

644641
# This will be filled in if a project is later identified to be the
645642
# project containing repo hooks.

repo

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ repodir = ".repo" # name of repo's private directory
215215
S_repo = "repo" # special repo repository
216216
S_manifests = "manifests" # special manifest repository
217217
REPO_MAIN = S_repo + "/main.py" # main script
218-
GITC_CONFIG_FILE = "/gitc/.config"
219-
GITC_FS_ROOT_DIR = "/gitc/manifest-rw/"
220218

221219

222220
import collections
@@ -235,12 +233,9 @@ home_dot_repo = os.path.join(repo_config_dir, ".repoconfig")
235233
gpg_dir = os.path.join(home_dot_repo, "gnupg")
236234

237235

238-
def GetParser(gitc_init=False):
236+
def GetParser():
239237
"""Setup the CLI parser."""
240-
if gitc_init:
241-
sys.exit("repo: fatal: GITC not supported.")
242-
else:
243-
usage = "repo init [options] [-u] url"
238+
usage = "repo init [options] [-u] url"
244239

245240
parser = optparse.OptionParser(usage=usage)
246241
InitParser(parser)
@@ -557,49 +552,6 @@ def run_command(cmd, **kwargs):
557552
return ret
558553

559554

560-
_gitc_manifest_dir = None
561-
562-
563-
def get_gitc_manifest_dir():
564-
global _gitc_manifest_dir
565-
if _gitc_manifest_dir is None:
566-
_gitc_manifest_dir = ""
567-
try:
568-
with open(GITC_CONFIG_FILE) as gitc_config:
569-
for line in gitc_config:
570-
match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line)
571-
if match:
572-
_gitc_manifest_dir = match.group("gitc_manifest_dir")
573-
except OSError:
574-
pass
575-
return _gitc_manifest_dir
576-
577-
578-
def gitc_parse_clientdir(gitc_fs_path):
579-
"""Parse a path in the GITC FS and return its client name.
580-
581-
Args:
582-
gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR.
583-
584-
Returns:
585-
The GITC client name.
586-
"""
587-
if gitc_fs_path == GITC_FS_ROOT_DIR:
588-
return None
589-
if not gitc_fs_path.startswith(GITC_FS_ROOT_DIR):
590-
manifest_dir = get_gitc_manifest_dir()
591-
if manifest_dir == "":
592-
return None
593-
if manifest_dir[-1] != "/":
594-
manifest_dir += "/"
595-
if gitc_fs_path == manifest_dir:
596-
return None
597-
if not gitc_fs_path.startswith(manifest_dir):
598-
return None
599-
return gitc_fs_path.split(manifest_dir)[1].split("/")[0]
600-
return gitc_fs_path.split(GITC_FS_ROOT_DIR)[1].split("/")[0]
601-
602-
603555
class CloneFailure(Exception):
604556

605557
"""Indicate the remote clone of repo itself failed."""
@@ -638,9 +590,9 @@ def check_repo_rev(dst, rev, repo_verify=True, quiet=False):
638590
return (remote_ref, rev)
639591

640592

641-
def _Init(args, gitc_init=False):
593+
def _Init(args):
642594
"""Installs repo by cloning it over the network."""
643-
parser = GetParser(gitc_init=gitc_init)
595+
parser = GetParser()
644596
opt, args = parser.parse_args(args)
645597
if args:
646598
if not opt.manifest_url:
@@ -1164,7 +1116,7 @@ class _Options:
11641116
def _ExpandAlias(name):
11651117
"""Look up user registered aliases."""
11661118
# We don't resolve aliases for existing subcommands. This matches git.
1167-
if name in {"gitc-init", "help", "init"}:
1119+
if name in {"help", "init"}:
11681120
return name, []
11691121

11701122
alias = _GetRepoConfig(f"alias.{name}")
@@ -1292,10 +1244,6 @@ class Requirements:
12921244

12931245

12941246
def _Usage():
1295-
gitc_usage = ""
1296-
if get_gitc_manifest_dir():
1297-
gitc_usage = " gitc-init Initialize a GITC Client.\n"
1298-
12991247
print(
13001248
"""usage: repo COMMAND [ARGS]
13011249
@@ -1304,9 +1252,7 @@ repo is not yet installed. Use "repo init" to install it here.
13041252
The most commonly used repo commands are:
13051253
13061254
init Install repo in the current working directory
1307-
"""
1308-
+ gitc_usage
1309-
+ """ help Display detailed help on a command
1255+
help Display detailed help on a command
13101256
13111257
For access to the full online help, install repo ("repo init").
13121258
"""
@@ -1317,8 +1263,8 @@ For access to the full online help, install repo ("repo init").
13171263

13181264
def _Help(args):
13191265
if args:
1320-
if args[0] in {"init", "gitc-init"}:
1321-
parser = GetParser(gitc_init=args[0] == "gitc-init")
1266+
if args[0] in {"init"}:
1267+
parser = GetParser()
13221268
parser.print_help()
13231269
sys.exit(0)
13241270
else:
@@ -1407,23 +1353,11 @@ def main(orig_args):
14071353
# We run this early as we run some git commands ourselves.
14081354
SetGitTrace2ParentSid()
14091355

1410-
repo_main, rel_repo_dir = None, None
1411-
# Don't use the local repo copy, make sure to switch to the gitc client first.
1412-
if cmd != "gitc-init":
1413-
repo_main, rel_repo_dir = _FindRepo()
1356+
repo_main, rel_repo_dir = _FindRepo()
14141357

14151358
wrapper_path = os.path.abspath(__file__)
14161359
my_main, my_git = _RunSelf(wrapper_path)
14171360

1418-
cwd = os.getcwd()
1419-
if get_gitc_manifest_dir() and cwd.startswith(get_gitc_manifest_dir()):
1420-
print(
1421-
"error: repo cannot be used in the GITC local manifest directory."
1422-
"\nIf you want to work on this GITC client please rerun this "
1423-
"command from the corresponding client under /gitc/",
1424-
file=sys.stderr,
1425-
)
1426-
sys.exit(1)
14271361
if not repo_main:
14281362
# Only expand aliases here since we'll be parsing the CLI ourselves.
14291363
# If we had repo_main, alias expansion would happen in main.py.
@@ -1438,11 +1372,11 @@ def main(orig_args):
14381372
_Version()
14391373
if not cmd:
14401374
_NotInstalled()
1441-
if cmd == "init" or cmd == "gitc-init":
1375+
if cmd == "init":
14421376
if my_git:
14431377
_SetDefaultsTo(my_git)
14441378
try:
1445-
_Init(args, gitc_init=(cmd == "gitc-init"))
1379+
_Init(args)
14461380
except CloneFailure:
14471381
path = os.path.join(repodir, S_repo)
14481382
print(

tests/fixtures/gitc_config

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test_wrapper.py

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -72,84 +72,11 @@ def test_python_constraints(self):
7272

7373
def test_init_parser(self):
7474
"""Make sure 'init' GetParser works."""
75-
parser = self.wrapper.GetParser(gitc_init=False)
75+
parser = self.wrapper.GetParser()
7676
opts, args = parser.parse_args([])
7777
self.assertEqual([], args)
7878
self.assertIsNone(opts.manifest_url)
7979

80-
def test_gitc_init_parser(self):
81-
"""Make sure 'gitc-init' GetParser raises."""
82-
with self.assertRaises(SystemExit):
83-
self.wrapper.GetParser(gitc_init=True)
84-
85-
def test_get_gitc_manifest_dir_no_gitc(self):
86-
"""
87-
Test reading a missing gitc config file
88-
"""
89-
self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config")
90-
val = self.wrapper.get_gitc_manifest_dir()
91-
self.assertEqual(val, "")
92-
93-
def test_get_gitc_manifest_dir(self):
94-
"""
95-
Test reading the gitc config file and parsing the directory
96-
"""
97-
self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config")
98-
val = self.wrapper.get_gitc_manifest_dir()
99-
self.assertEqual(val, "/test/usr/local/google/gitc")
100-
101-
def test_gitc_parse_clientdir_no_gitc(self):
102-
"""
103-
Test parsing the gitc clientdir without gitc running
104-
"""
105-
self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config")
106-
self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None)
107-
self.assertEqual(
108-
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test"
109-
)
110-
111-
def test_gitc_parse_clientdir(self):
112-
"""
113-
Test parsing the gitc clientdir
114-
"""
115-
self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config")
116-
self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None)
117-
self.assertEqual(
118-
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test"
119-
)
120-
self.assertEqual(
121-
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/"), "test"
122-
)
123-
self.assertEqual(
124-
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/extra"),
125-
"test",
126-
)
127-
self.assertEqual(
128-
self.wrapper.gitc_parse_clientdir(
129-
"/test/usr/local/google/gitc/test"
130-
),
131-
"test",
132-
)
133-
self.assertEqual(
134-
self.wrapper.gitc_parse_clientdir(
135-
"/test/usr/local/google/gitc/test/"
136-
),
137-
"test",
138-
)
139-
self.assertEqual(
140-
self.wrapper.gitc_parse_clientdir(
141-
"/test/usr/local/google/gitc/test/extra"
142-
),
143-
"test",
144-
)
145-
self.assertEqual(
146-
self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/"), None
147-
)
148-
self.assertEqual(
149-
self.wrapper.gitc_parse_clientdir("/test/usr/local/google/gitc/"),
150-
None,
151-
)
152-
15380

15481
class SetGitTrace2ParentSid(RepoWrapperTestCase):
15582
"""Check SetGitTrace2ParentSid behavior."""

0 commit comments

Comments
 (0)