|
|
|
@ -777,87 +777,6 @@ class TestGitCl(TestCase):
|
|
|
|
|
change_id = git_cl.GenerateGerritChangeId('line1\nline2\n')
|
|
|
|
|
self.assertEqual(change_id, 'Ihashchange')
|
|
|
|
|
|
|
|
|
|
def test_config_gerrit_download_hook(self):
|
|
|
|
|
self.mock(git_cl, 'FindCodereviewSettingsFile', CodereviewSettingsFileMock)
|
|
|
|
|
def ParseCodereviewSettingsContent(content):
|
|
|
|
|
keyvals = {}
|
|
|
|
|
keyvals['CODE_REVIEW_SERVER'] = 'gerrit.chromium.org'
|
|
|
|
|
keyvals['GERRIT_HOST'] = 'True'
|
|
|
|
|
return keyvals
|
|
|
|
|
self.mock(git_cl.gclient_utils, 'ParseCodereviewSettingsContent',
|
|
|
|
|
ParseCodereviewSettingsContent)
|
|
|
|
|
self.mock(git_cl.os, 'access', self._mocked_call)
|
|
|
|
|
self.mock(git_cl.os, 'chmod', self._mocked_call)
|
|
|
|
|
src_dir = os.path.join(os.path.sep, 'usr', 'local', 'src')
|
|
|
|
|
def AbsPath(path):
|
|
|
|
|
if not path.startswith(os.path.sep):
|
|
|
|
|
return os.path.join(src_dir, path)
|
|
|
|
|
return path
|
|
|
|
|
self.mock(git_cl.os.path, 'abspath', AbsPath)
|
|
|
|
|
commit_msg_path = os.path.join(src_dir, '.git', 'hooks', 'commit-msg')
|
|
|
|
|
def Exists(path):
|
|
|
|
|
if path == commit_msg_path:
|
|
|
|
|
return False
|
|
|
|
|
# others paths, such as /usr/share/locale/....
|
|
|
|
|
return True
|
|
|
|
|
self.mock(git_cl.os.path, 'exists', Exists)
|
|
|
|
|
self.mock(git_cl, 'urlretrieve', self._mocked_call)
|
|
|
|
|
self.mock(git_cl, 'hasSheBang', self._mocked_call)
|
|
|
|
|
self.calls = [
|
|
|
|
|
((['git', 'config', 'rietveld.autoupdate'],),
|
|
|
|
|
''),
|
|
|
|
|
((['git', 'config', 'rietveld.server',
|
|
|
|
|
'gerrit.chromium.org'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all', 'rietveld.cc'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.private'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.tree-status-url'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.viewvc-url'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.bug-prefix'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.cpplint-regex'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.force-https-commit-url'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.cpplint-ignore-regex'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.project'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.pending-ref-prefix'],), ''),
|
|
|
|
|
((['git', 'config', '--unset-all',
|
|
|
|
|
'rietveld.run-post-upload-hook'],), ''),
|
|
|
|
|
((['git', 'config', 'gerrit.host', 'True'],), ''),
|
|
|
|
|
# GetCodereviewSettingsInteractively
|
|
|
|
|
((['git', 'config', 'rietveld.server'],),
|
|
|
|
|
'gerrit.chromium.org'),
|
|
|
|
|
(('Rietveld server (host[:port]) [https://gerrit.chromium.org]:',),
|
|
|
|
|
''),
|
|
|
|
|
((['git', 'config', 'rietveld.cc'],), ''),
|
|
|
|
|
(('CC list:',), ''),
|
|
|
|
|
((['git', 'config', 'rietveld.private'],), ''),
|
|
|
|
|
(('Private flag (rietveld only):',), ''),
|
|
|
|
|
((['git', 'config', 'rietveld.tree-status-url'],), ''),
|
|
|
|
|
(('Tree status URL:',), ''),
|
|
|
|
|
((['git', 'config', 'rietveld.viewvc-url'],), ''),
|
|
|
|
|
(('ViewVC URL:',), ''),
|
|
|
|
|
((['git', 'config', 'rietveld.bug-prefix'],), ''),
|
|
|
|
|
(('Bug Prefix:',), ''),
|
|
|
|
|
((['git', 'config', 'rietveld.run-post-upload-hook'],), ''),
|
|
|
|
|
(('Run Post Upload Hook:',), ''),
|
|
|
|
|
# DownloadGerritHook(False)
|
|
|
|
|
((['git', 'config', 'gerrit.host'],), 'True'),
|
|
|
|
|
((['git', 'rev-parse', '--show-cdup'],), ''),
|
|
|
|
|
((commit_msg_path, os.X_OK,), False),
|
|
|
|
|
(('https://gerrit-review.googlesource.com/tools/hooks/commit-msg',
|
|
|
|
|
commit_msg_path,), ''),
|
|
|
|
|
((commit_msg_path,), True),
|
|
|
|
|
((commit_msg_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,), ''),
|
|
|
|
|
]
|
|
|
|
|
git_cl.main(['config'])
|
|
|
|
|
|
|
|
|
|
def test_update_reviewers(self):
|
|
|
|
|
data = [
|
|
|
|
|
('foo', [], 'foo'),
|
|
|
|
|