From 88cc0b8ca8ab9103b94db6552e9f1ed4789445a8 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Thu, 9 Nov 2023 19:19:23 +0000 Subject: [PATCH] Remove old Cog detection This is no longer needed. R=aravindvasudev@google.com Change-Id: Ic1b2bbf0f00ca9d288c21fa1623c4ada80d59644 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5014581 Commit-Queue: Josip Sokcevic Reviewed-by: Aravind Vasudevan --- fetch.py | 6 ------ gclient_scm.py | 40 ++++++--------------------------------- tests/gclient_scm_test.py | 22 --------------------- 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/fetch.py b/fetch.py index 3fcbc5e8b..f20b1e8f8 100755 --- a/fetch.py +++ b/fetch.py @@ -274,12 +274,6 @@ def run(options, spec, root): checkout_type = spec['type'] checkout_spec = spec['%s_spec' % checkout_type] - # Use sso:// by default if the env is cog - if not options.protocol_override and \ - (any(os.getcwd().startswith(x) for x in [ - '/google/src/cloud', '/google/cog/cloud'])): - options.protocol_override = 'sso' - # Update solutions with protocol_override field if options.protocol_override is not None: for solution in checkout_spec['solutions']: diff --git a/gclient_scm.py b/gclient_scm.py index a9f665ec3..ceb58dc9e 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -213,18 +213,6 @@ class GitWrapper(SCMWrapper): name = 'git' remote = 'origin' - _is_env_cog = None - - @staticmethod - def _IsCog(): - """Returns true if the env is cog""" - if not GitWrapper._is_env_cog: - GitWrapper._is_env_cog = any( - os.getcwd().startswith(x) - for x in ['/google/cog/cloud', '/google/src/cloud']) - - return GitWrapper._is_env_cog - @property def cache_dir(self): try: @@ -1220,12 +1208,11 @@ class GitWrapper(SCMWrapper): def _Clone(self, revision, url, options): """Clone a git repository from the given URL. - Once we've cloned the repo, we checkout a working branch if the specified - revision is a branch head. If it is a tag or a specific commit, then we - leave HEAD detached as it makes future updates simpler -- in this case the - user should first create a new branch or switch to an existing branch before - making changes in the repo.""" - in_cog_workspace = self._IsCog() + Once we've cloned the repo, we checkout a working branch if the + specified revision is a branch head. If it is a tag or a specific + commit, then we leave HEAD detached as it makes future updates simpler + -- in this case the user should first create a new branch or switch to + an existing branch before making changes in the repo.""" if self.print_outbuf: print_stdout = True @@ -1244,22 +1231,7 @@ class GitWrapper(SCMWrapper): parent_dir = os.path.dirname(self.checkout_path) gclient_utils.safe_makedirs(parent_dir) - if in_cog_workspace: - clone_cmd = ['citc', 'clone-repo', url, self.checkout_path] - clone_cmd.append( - gclient_utils.ExtractRefName(self.remote, revision) or revision) - try: - self._Run(clone_cmd, - options, - cwd=self._root_dir, - retry=True, - print_stdout=print_stdout, - filter_fn=filter_fn) - except: - traceback.print_exc(file=self.out_fh) - raise - self._SetFetchConfig(options) - elif hasattr(options, 'no_history') and options.no_history: + if hasattr(options, 'no_history') and options.no_history: self._Run(['init', self.checkout_path], options, cwd=self._root_dir) self._Run(['remote', 'add', 'origin', url], options) revision = self._AutoFetchRef(options, revision, depth=1) diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index e90f25d6c..3b3c8794c 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -237,28 +237,6 @@ from :3 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): - @mock.patch('gclient_scm.GitWrapper._IsCog') - @mock.patch('gclient_scm.GitWrapper._Run', return_value=True) - @mock.patch('gclient_scm.GitWrapper._SetFetchConfig') - @mock.patch('gclient_scm.GitWrapper._GetCurrentBranch') - def testCloneInCog(self, mockGetCurrentBranch, mockSetFetchConfig, mockRun, - _mockIsCog): - """Test that we call the correct commands when in a cog workspace.""" - if not self.enabled: - return - options = self.Options() - scm = gclient_scm.GitWrapper(self.url, self.root_dir, self.relpath) - scm._Clone('123123ab', self.url, options) - mockRun.assert_called_once_with( - ['citc', 'clone-repo', self.url, scm.checkout_path, '123123ab'], - options, - cwd=scm._root_dir, - retry=True, - print_stdout=False, - filter_fn=scm.filter) - mockSetFetchConfig.assert_called_once() - mockGetCurrentBranch.assert_called_once() - def testRevertMissing(self): if not self.enabled: return