From 269640724f824eff2b21faeebb2b44bf84fa5881 Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Wed, 19 Feb 2020 19:18:51 +0000 Subject: [PATCH] git-cl: Use scm.GIT.GetConfig in more places. Bug: 1051631 Change-Id: I43460b72dfbc9c8210c2d8fdf5d29e876a5637f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2056648 Reviewed-by: Anthony Polito Commit-Queue: Edward Lesmes --- git_cl.py | 88 ++++++++++---------- tests/git_cl_test.py | 190 +++++++++++++------------------------------ 2 files changed, 97 insertions(+), 181 deletions(-) diff --git a/git_cl.py b/git_cl.py index f4eb62b6d..4faae4928 100755 --- a/git_cl.py +++ b/git_cl.py @@ -793,20 +793,22 @@ class Settings(object): self.git_editor = None self.format_full_by_default = None - def LazyUpdateIfNeeded(self): + def _LazyUpdateIfNeeded(self): """Updates the settings from a codereview.settings file, if available.""" - if not self.updated: - # The only value that actually changes the behavior is - # autoupdate = "false". Everything else means "true". - autoupdate = RunGit(['config', 'rietveld.autoupdate'], - error_ok=True - ).strip().lower() - - cr_settings_file = FindCodereviewSettingsFile() - if autoupdate != 'false' and cr_settings_file: - LoadCodereviewSettingsFromFile(cr_settings_file) - cr_settings_file.close() - self.updated = True + if self.updated: + return + + # The only value that actually changes the behavior is + # autoupdate = "false". Everything else means "true". + autoupdate = ( + scm.GIT.GetConfig(self.GetRoot(), 'rietveld.autoupdate', '').lower()) + + cr_settings_file = FindCodereviewSettingsFile() + if autoupdate != 'false' and cr_settings_file: + LoadCodereviewSettingsFromFile(cr_settings_file) + cr_settings_file.close() + + self.updated = True @staticmethod def GetRelativeRoot(): @@ -819,45 +821,43 @@ class Settings(object): def GetTreeStatusUrl(self, error_ok=False): if not self.tree_status_url: - error_message = ('You must configure your tree status URL by running ' - '"git cl config".') - self.tree_status_url = self._GetConfig( - 'rietveld.tree-status-url', error_ok=error_ok, - error_message=error_message) + self.tree_status_url = self._GetConfig('rietveld.tree-status-url') + if self.tree_status_url is None and not error_ok: + DieWithError( + 'You must configure your tree status URL by running ' + '"git cl config".') return self.tree_status_url def GetViewVCUrl(self): if not self.viewvc_url: - self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) + self.viewvc_url = self._GetConfig('rietveld.viewvc-url') return self.viewvc_url def GetBugPrefix(self): - return self._GetConfig('rietveld.bug-prefix', error_ok=True) + return self._GetConfig('rietveld.bug-prefix') def GetRunPostUploadHook(self): run_post_upload_hook = self._GetConfig( - 'rietveld.run-post-upload-hook', error_ok=True) + 'rietveld.run-post-upload-hook') return run_post_upload_hook == "True" def GetDefaultCCList(self): - return self._GetConfig('rietveld.cc', error_ok=True) + return self._GetConfig('rietveld.cc') def GetIsGerrit(self): """Returns True if this repo is associated with Gerrit.""" if self.is_gerrit is None: - self.is_gerrit = ( - self._GetConfig('gerrit.host', error_ok=True).lower() == 'true') + self.is_gerrit = self._GetConfig('gerrit.host').lower() == 'true' return self.is_gerrit def GetSquashGerritUploads(self): """Returns True if uploads to Gerrit should be squashed by default.""" if self.squash_gerrit_uploads is None: self.squash_gerrit_uploads = self.GetSquashGerritUploadsOverride() - if self.squash_gerrit_uploads is None: - # Default is squash now (http://crbug.com/611892#c23). - self.squash_gerrit_uploads = not ( - RunGit(['config', '--bool', 'gerrit.squash-uploads'], - error_ok=True).strip() == 'false') + if self.squash_gerrit_uploads is None: + # Default is squash now (http://crbug.com/611892#c23). + self.squash_gerrit_uploads = self._GetConfig( + 'gerrit.squash-uploads').lower() != 'false' return self.squash_gerrit_uploads def GetSquashGerritUploadsOverride(self): @@ -866,8 +866,7 @@ class Settings(object): Returns None if no override has been defined. """ # See also http://crbug.com/611892#c23 - result = RunGit(['config', '--bool', 'gerrit.override-squash-uploads'], - error_ok=True).strip() + result = self._GetConfig('gerrit.override-squash-uploads').lower() if result == 'true': return True if result == 'false': @@ -878,9 +877,8 @@ class Settings(object): """Return True if EnsureAuthenticated should not be done for Gerrit uploads.""" if self.gerrit_skip_ensure_authenticated is None: - self.gerrit_skip_ensure_authenticated = ( - RunGit(['config', '--bool', 'gerrit.skip-ensure-authenticated'], - error_ok=True).strip() == 'true') + self.gerrit_skip_ensure_authenticated = self._GetConfig( + 'gerrit.skip-ensure-authenticated').lower() == 'true' return self.gerrit_skip_ensure_authenticated def GetGitEditor(self): @@ -889,17 +887,15 @@ class Settings(object): # Git requires single quotes for paths with spaces. We need to replace # them with double quotes for Windows to treat such paths as a single # path. - self.git_editor = self._GetConfig( - 'core.editor', error_ok=True).replace('\'', '"') + self.git_editor = self._GetConfig('core.editor').replace('\'', '"') return self.git_editor or None def GetLintRegex(self): - return (self._GetConfig('rietveld.cpplint-regex', error_ok=True) or - DEFAULT_LINT_REGEX) + return self._GetConfig('rietveld.cpplint-regex', DEFAULT_LINT_REGEX) def GetLintIgnoreRegex(self): - return (self._GetConfig('rietveld.cpplint-ignore-regex', error_ok=True) or - DEFAULT_LINT_IGNORE_REGEX) + return self._GetConfig( + 'rietveld.cpplint-ignore-regex', DEFAULT_LINT_IGNORE_REGEX) def GetFormatFullByDefault(self): if self.format_full_by_default is None: @@ -909,9 +905,9 @@ class Settings(object): self.format_full_by_default = (result == 'true') return self.format_full_by_default - def _GetConfig(self, param, **kwargs): - self.LazyUpdateIfNeeded() - return RunGit(['config', param], **kwargs).strip() + def _GetConfig(self, key, default=''): + self._LazyUpdateIfNeeded() + return scm.GIT.GetConfig(self.GetRoot(), key, default) class _CQState(object): @@ -1234,7 +1230,7 @@ class Changelist(object): return value remote, _ = self.GetRemoteBranch() - url = RunGit(['config', 'remote.%s.url' % remote], error_ok=True).strip() + url = scm.GIT.GetConfig(settings.GetRoot(), 'remote.%s.url' % remote, '') # Check if the remote url can be parsed as an URL. host = urllib.parse.urlparse(url).netloc @@ -1254,9 +1250,7 @@ class Changelist(object): return None cache_path = url - url = RunGit(['config', 'remote.%s.url' % remote], - error_ok=True, - cwd=url).strip() + url = scm.GIT.GetConfig(url, 'remote.%s.url' % remote, '') host = urllib.parse.urlparse(url).netloc if not host: diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 901d96b04..0cb1831aa 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -112,10 +112,14 @@ class GitMocks(object): def NewBranch(self, branchref): self.branchref = branchref - def GetConfig(self, _root, key, default=None): + def GetConfig(self, root, key, default=None): + if root != '': + key = '%s:%s' % (root, key) return self.config.get(key, default) - def SetConfig(self, _root, key, value=None): + def SetConfig(self, root, key, value=None): + if root != '': + key = '%s:%s' % (root, key) if value: self.config[key] = value return @@ -707,12 +711,13 @@ class TestGitCl(unittest.TestCase): 'A few following expected calls:\n %s' % (prior_calls, len(self._calls_done), expected_args, len(self._calls_done), args, following_calls)) - git_cl.logging.error(extended_msg) self.fail('@%d\n' ' Expected: %r\n' - ' Actual: %r' % ( - len(self._calls_done), expected_args, args)) + ' Actual: %r\n' + '\n' + '%s' % ( + len(self._calls_done), expected_args, args, extended_msg)) self._calls_done.append(top) if isinstance(result, Exception): @@ -748,18 +753,6 @@ class TestGitCl(unittest.TestCase): ] self.assertIsNone(git_cl.LoadCodereviewSettingsFromFile(codereview_file)) - @classmethod - def _is_gerrit_calls(cls, gerrit=False): - return [((['git', 'config', 'rietveld.autoupdate'],), ''), - ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] - - @classmethod - def _git_post_upload_calls(cls): - return [ - ((['git', 'rev-parse', 'HEAD'],), 'hash'), - ((['git', 'config', 'rietveld.run-post-upload-hook'],), ''), - ] - @staticmethod def _git_sanity_checks(diff_base, working_branch, get_remote_branch=True): fake_ancestor = 'fake_ancestor' @@ -786,30 +779,12 @@ class TestGitCl(unittest.TestCase): 'refs/remotes/origin/master'],), ''), ] - @classmethod - def _gerrit_ensure_auth_calls( - cls, issue=None, skip_auth_check=False, short_hostname='chromium', - custom_cl_base=None): - cmd = ['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'] - if skip_auth_check: - return [((cmd, ), 'true')] - - calls = [((cmd, ), CERR1)] - - calls.extend([ - ((['git', 'config', 'remote.origin.url'],), - 'https://%s.googlesource.com/my/repo' % short_hostname) - ]) - - return calls - @classmethod def _gerrit_base_calls(cls, issue=None, fetched_description=None, fetched_status=None, other_cl_owner=None, custom_cl_base=None, short_hostname='chromium', change_id=None): - calls = cls._is_gerrit_calls(True) - + calls = [] if custom_cl_base: ancestor_revision = custom_cl_base else: @@ -820,11 +795,6 @@ class TestGitCl(unittest.TestCase): ancestor_revision), ] - # Calls to verify branch point is ancestor - calls += cls._gerrit_ensure_auth_calls( - issue=issue, short_hostname=short_hostname, - custom_cl_base=custom_cl_base) - if issue: calls += [ (('GetChangeDetail', '%s-review.googlesource.com' % short_hostname, @@ -882,8 +852,7 @@ class TestGitCl(unittest.TestCase): ] return calls - @classmethod - def _gerrit_upload_calls(cls, description, reviewers, squash, + def _gerrit_upload_calls(self, description, reviewers, squash, squash_mode='default', expected_upstream_ref='origin/refs/heads/master', title=None, notify=False, @@ -901,18 +870,9 @@ class TestGitCl(unittest.TestCase): calls = [] - if squash_mode == 'default': - calls.extend([ - ((['git', 'config', '--bool', 'gerrit.override-squash-uploads'],), ''), - ((['git', 'config', '--bool', 'gerrit.squash-uploads'],), ''), - ]) - elif squash_mode in ('override_squash', 'override_nosquash'): - calls.extend([ - ((['git', 'config', '--bool', 'gerrit.override-squash-uploads'],), - 'true' if squash_mode == 'override_squash' else 'false'), - ]) - else: - assert squash_mode in ('squash', 'nosquash') + if squash_mode in ('override_squash', 'override_nosquash'): + self.mockGit.config['gerrit.override-squash-uploads'] = ( + 'true' if squash_mode == 'override_squash' else 'false') # If issue is given, then description is fetched from Gerrit instead. if issue is None: @@ -945,24 +905,13 @@ class TestGitCl(unittest.TestCase): ] if squash: if force or not issue: - if issue: - calls += [ - ((['git', 'config', 'rietveld.bug-prefix'],), ''), - ] - # Prompting to edit description on first upload. - calls += [ - ((['git', 'config', 'rietveld.bug-prefix'],), ''), - ] if not force: calls += [ - ((['git', 'config', 'core.editor'],), ''), ((['RunEditor'],), description), ] # user wants to edit description if edit_description: calls += [ - ((['git', 'config', 'rietveld.bug-prefix'],), ''), - ((['git', 'config', 'core.editor'],), ''), ((['RunEditor'],), edit_description), ] ref_to_push = 'abcdef0123456789' @@ -1022,10 +971,6 @@ class TestGitCl(unittest.TestCase): ref_suffix += ',m=' + title metrics_arguments.append('m') - if issue is None: - calls += [ - ((['git', 'config', 'rietveld.cc'],), ''), - ] if short_hostname == 'chromium': # All reviwers and ccs get into ref_suffix. for r in sorted(reviewers): @@ -1183,7 +1128,9 @@ class TestGitCl(unittest.TestCase): notify), ''), ] - calls += cls._git_post_upload_calls() + calls += [ + ((['git', 'rev-parse', 'HEAD'],), 'hash'), + ] return calls def _run_gerrit_upload_test( @@ -1256,6 +1203,7 @@ class TestGitCl(unittest.TestCase): mock.patch('os.path.isfile', lambda path: self._mocked_call(['os.path.isfile', path])).start() + self.mockGit.config['gerrit.host'] = 'true' self.mockGit.config['branch.master.gerritissue'] = ( str(issue) if issue else None) self.mockGit.config['remote.origin.url'] = ( @@ -1295,14 +1243,10 @@ class TestGitCl(unittest.TestCase): # print('\n'.join(map(lambda x: '%2i: %s' % x, enumerate(self.calls)))) git_cl.main(['upload'] + upload_args) if squash: - self.assertEqual( - '123456', scm.GIT.GetBranchConfig(None, 'master', 'gerritissue')) - self.assertEqual( - 'https://chromium-review.googlesource.com', - scm.GIT.GetBranchConfig(None, 'master', 'gerritserver')) + self.assertIssueAndPatchset(patchset=None) self.assertEqual( 'abcdef0123456789', - scm.GIT.GetBranchConfig(None, 'master', 'gerritsquashhash')) + scm.GIT.GetBranchConfig('', 'master', 'gerritsquashhash')) def test_gerrit_upload_traces_no_gitcookies(self): self._run_gerrit_upload_test( @@ -1759,19 +1703,19 @@ class TestGitCl(unittest.TestCase): self, branch='master', issue='123456', patchset='7', git_short_host='chromium'): self.assertEqual( - issue, scm.GIT.GetBranchConfig(None, branch, 'gerritissue')) + issue, scm.GIT.GetBranchConfig('', branch, 'gerritissue')) self.assertEqual( - patchset, scm.GIT.GetBranchConfig(None, branch, 'gerritpatchset')) + patchset, scm.GIT.GetBranchConfig('', branch, 'gerritpatchset')) self.assertEqual( 'https://%s-review.googlesource.com' % git_short_host, - scm.GIT.GetBranchConfig(None, branch, 'gerritserver')) + scm.GIT.GetBranchConfig('', branch, 'gerritserver')) def _patch_common(self, git_short_host='chromium'): mock.patch('git_cl.IsGitVersionAtLeast', return_value=True).start() + self.mockGit.config['remote.origin.url'] = ( + 'https://%s.googlesource.com/my/repo' % git_short_host) self.calls += [ - ((['git', 'config', 'remote.origin.url'],), - 'https://%s.googlesource.com/my/repo' % git_short_host), (('GetChangeDetail', git_short_host + '-review.googlesource.com', 'my%2Frepo~123456', ['ALL_REVISIONS', 'CURRENT_COMMIT']), { @@ -1869,9 +1813,9 @@ class TestGitCl(unittest.TestCase): 'git_cl.gerrit_util.GetChangeDetail', side_effect=gerrit_util.GerritError(404, '')) def test_patch_gerrit_not_exists(self, *_mocks): + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/my/repo') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/my/repo'), (('DieWithError', 'change 123456 at https://chromium-review.googlesource.com does not ' 'exist or you have no access to it'), SystemExitMock()), @@ -1906,11 +1850,11 @@ class TestGitCl(unittest.TestCase): ] self.assertEqual(1, git_cl.main(['checkout', '99999'])) - def _test_gerrit_ensure_authenticated_common(self, auth, - skip_auth_check=False): + def _test_gerrit_ensure_authenticated_common(self, auth): mock.patch('git_cl.gerrit_util.CookiesAuthenticator', CookiesAuthenticatorMockFactory(hosts_with_creds=auth)).start() - self.calls = self._gerrit_ensure_auth_calls(skip_auth_check=skip_auth_check) + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/my/repo') cl = git_cl.Changelist() cl.branch = 'master' cl.branchref = 'refs/heads/master' @@ -1951,8 +1895,8 @@ class TestGitCl(unittest.TestCase): self.assertIsNone(cl.EnsureAuthenticated(force=False)) def test_gerrit_ensure_authenticated_skipped(self): - cl = self._test_gerrit_ensure_authenticated_common( - auth={}, skip_auth_check=True) + self.mockGit.config['gerrit.skip-ensure-authenticated'] = 'true' + cl = self._test_gerrit_ensure_authenticated_common(auth={}) self.assertIsNone(cl.EnsureAuthenticated(force=False)) def test_gerrit_ensure_authenticated_bearer_token(self): @@ -1968,10 +1912,8 @@ class TestGitCl(unittest.TestCase): self.assertTrue('Bearer' in header) def test_gerrit_ensure_authenticated_non_https(self): + self.mockGit.config['remote.origin.url'] = 'custom-scheme://repo' self.calls = [ - ((['git', 'config', '--bool', - 'gerrit.skip-ensure-authenticated'],), CERR1), - ((['git', 'config', 'remote.origin.url'],), 'custom-scheme://repo'), (('logging.warning', 'Ignoring branch %(branch)s with non-https remote ' '%(remote)s', { @@ -1990,11 +1932,9 @@ class TestGitCl(unittest.TestCase): self.assertIsNone(cl.EnsureAuthenticated(force=False)) def test_gerrit_ensure_authenticated_non_url(self): + self.mockGit.config['remote.origin.url'] = ( + 'git@somehost.example:foo/bar.git') self.calls = [ - ((['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'], ), - CERR1), - ((['git', 'config', 'remote.origin.url'], ), - 'git@somehost.example:foo/bar.git'), (('logging.error', 'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", ' 'but it doesn\'t exist.', { @@ -2017,9 +1957,9 @@ class TestGitCl(unittest.TestCase): self.mockGit.config['branch.master.gerritissue'] = '123' self.mockGit.config['branch.master.gerritserver'] = ( 'https://chromium-review.googlesource.com') + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/infra/infra') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/infra/infra.git'), (('SetReview', 'chromium-review.googlesource.com', 'infra%2Finfra~123', None, {'Commit-Queue': vote}, notify, None), ''), @@ -2076,9 +2016,9 @@ class TestGitCl(unittest.TestCase): git_cl.main(['set-close', '--issue', '1']), 0) def test_description(self): + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/my/repo') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/my/repo'), (('GetChangeDetail', 'chromium-review.googlesource.com', 'my%2Frepo~123123', ['CURRENT_REVISION', 'CURRENT_COMMIT']), { @@ -2126,12 +2066,6 @@ class TestGitCl(unittest.TestCase): mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start() self.mockGit.config['branch.master.gerritissue'] = '123' - - self.calls = [ - ((['git', 'config', 'rietveld.autoupdate'],), CERR1), - ((['git', 'config', 'rietveld.bug-prefix'],), CERR1), - ((['git', 'config', 'core.editor'],), 'vi'), - ] self.assertEqual(0, git_cl.main(['description'])) def test_description_does_not_append_bug_line_if_fixed_is_present(self): @@ -2153,12 +2087,6 @@ class TestGitCl(unittest.TestCase): mock.patch('git_cl.gclient_utils.RunEditor', RunEditor).start() self.mockGit.config['branch.master.gerritissue'] = '123' - - self.calls = [ - ((['git', 'config', 'rietveld.autoupdate'],), CERR1), - ((['git', 'config', 'rietveld.bug-prefix'],), CERR1), - ((['git', 'config', 'core.editor'],), 'vi'), - ] self.assertEqual(0, git_cl.main(['description'])) def test_description_set_stdin(self): @@ -2536,9 +2464,9 @@ class TestGitCl(unittest.TestCase): def test_git_cl_comment_add_gerrit(self): self.mockGit.branchref = None + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/infra/infra') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/infra/infra'), (('SetReview', 'chromium-review.googlesource.com', 'infra%2Finfra~10', 'msg', None, None, None), None), @@ -2547,9 +2475,9 @@ class TestGitCl(unittest.TestCase): @mock.patch('git_cl.Changelist.GetBranch', return_value='foo') def test_git_cl_comments_fetch_gerrit(self, *_mocks): + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/infra/infra') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/infra/infra'), (('GetChangeDetail', 'chromium-review.googlesource.com', 'infra%2Finfra~1', ['MESSAGES', 'DETAILED_ACCOUNTS', 'CURRENT_REVISION', @@ -2690,9 +2618,9 @@ class TestGitCl(unittest.TestCase): # git cl comments also fetches robot comments (which are considered a type # of autogenerated comment), and unlike other types of comments, only robot # comments from the latest patchset are shown. + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/infra/infra') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/infra/infra'), (('GetChangeDetail', 'chromium-review.googlesource.com', 'infra%2Finfra~1', ['MESSAGES', 'DETAILED_ACCOUNTS', 'CURRENT_REVISION', @@ -2802,14 +2730,13 @@ class TestGitCl(unittest.TestCase): mock.patch('os.path.isdir', selective_os_path_isdir_mock).start() url = 'https://chromium.googlesource.com/my/repo' + self.mockGit.config['remote.origin.url'] = ( + '/cache/this-dir-exists') + self.mockGit.config['/cache/this-dir-exists:remote.origin.url'] = ( + url) self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - '/cache/this-dir-exists'), (('os.path.isdir', '/cache/this-dir-exists'), True), - # Runs in /cache/this-dir-exists. - ((['git', 'config', 'remote.origin.url'],), - url), ] cl = git_cl.Changelist(issue=1) self.assertEqual(cl.GetRemoteUrl(), url) @@ -2827,9 +2754,9 @@ class TestGitCl(unittest.TestCase): mock.patch('logging.error', lambda *a: self._mocked_call('logging.error', *a)).start() + self.mockGit.config['remote.origin.url'] = ( + '/cache/this-dir-doesnt-exist') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - '/cache/this-dir-doesnt-exist'), (('os.path.isdir', '/cache/this-dir-doesnt-exist'), False), (('logging.error', @@ -2855,12 +2782,10 @@ class TestGitCl(unittest.TestCase): mock.patch('logging.error', lambda *a: self._mocked_call('logging.error', *a)).start() + self.mockGit.config['remote.origin.url'] = ( + '/cache/this-dir-exists') self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - '/cache/this-dir-exists'), (('os.path.isdir', '/cache/this-dir-exists'), True), - # Runs in /cache/this-dir-exists. - ((['git', 'config', 'remote.origin.url'],), ''), (('logging.error', 'Remote "%(remote)s" for branch "%(branch)s" points to ' '"%(cache_path)s", but it is misconfigured.\n' @@ -2875,10 +2800,8 @@ class TestGitCl(unittest.TestCase): self.assertIsNone(cl.GetRemoteUrl()) def test_gerrit_change_identifier_with_project(self): - self.calls = [ - ((['git', 'config', 'remote.origin.url'],), - 'https://chromium.googlesource.com/a/my/repo.git/'), - ] + self.mockGit.config['remote.origin.url'] = ( + 'https://chromium.googlesource.com/a/my/repo.git/') cl = git_cl.Changelist(issue=123456) self.assertEqual(cl._GerritChangeIdentifier(), 'my%2Frepo~123456') @@ -2887,7 +2810,6 @@ class TestGitCl(unittest.TestCase): lambda *a: self._mocked_call('logging.error', *a)).start() self.calls = [ - ((['git', 'config', 'remote.origin.url'],), CERR1), (('logging.error', 'Remote "%(remote)s" for branch "%(branch)s" points to "%(url)s", ' 'but it doesn\'t exist.', {