Commit e7d3d165 authored by tandrii@chromium.org's avatar tandrii@chromium.org

Stop installing Gerrit commit-msg hooks in git cl config.

R=bauerb@chromium.org,ukai@chromium.org,andybons@chromium.org
BUG=579176,579160

Review URL: https://codereview.chromium.org/1799553003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299293 0039d316-1c4b-4281-b951-d872f2087c98
parent 6cf98c8b
......@@ -1333,47 +1333,6 @@ or verify this branch is set up to track another (via the --track argument to
return None
def GetCodereviewSettingsInteractively():
"""Prompt the user for settings."""
# TODO(ukai): ask code review system is rietveld or gerrit?
server = settings.GetDefaultServerUrl(error_ok=True)
prompt = 'Rietveld server (host[:port])'
prompt += ' [%s]' % (server or DEFAULT_SERVER)
newserver = ask_for_data(prompt + ':')
if not server and not newserver:
newserver = DEFAULT_SERVER
if newserver:
newserver = gclient_utils.UpgradeToHttps(newserver)
if newserver != server:
RunGit(['config', 'rietveld.server', newserver])
def SetProperty(initial, caption, name, is_url):
prompt = caption
if initial:
prompt += ' ("x" to clear) [%s]' % initial
new_val = ask_for_data(prompt + ':')
if new_val == 'x':
RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True)
elif new_val:
if is_url:
new_val = gclient_utils.UpgradeToHttps(new_val)
if new_val != initial:
RunGit(['config', 'rietveld.' + name, new_val])
SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False)
SetProperty(settings.GetDefaultPrivateFlag(),
'Private flag (rietveld only)', 'private', False)
SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL',
'tree-status-url', False)
SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True)
SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False)
SetProperty(settings.GetRunPostUploadHook(), 'Run Post Upload Hook',
'run-post-upload-hook', False)
# TODO: configure a default branch to diff against, rather than this
# svn-based hackery.
class ChangeDescription(object):
"""Contains a parsed form of the change description."""
R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$'
......@@ -1620,10 +1579,50 @@ def DownloadGerritHook(force):
# upgraded. See http://crbug.com/579176.
DownloadHooks = DownloadGerritHook
def GetRietveldCodereviewSettingsInteractively():
"""Prompt the user for settings."""
server = settings.GetDefaultServerUrl(error_ok=True)
prompt = 'Rietveld server (host[:port])'
prompt += ' [%s]' % (server or DEFAULT_SERVER)
newserver = ask_for_data(prompt + ':')
if not server and not newserver:
newserver = DEFAULT_SERVER
if newserver:
newserver = gclient_utils.UpgradeToHttps(newserver)
if newserver != server:
RunGit(['config', 'rietveld.server', newserver])
def SetProperty(initial, caption, name, is_url):
prompt = caption
if initial:
prompt += ' ("x" to clear) [%s]' % initial
new_val = ask_for_data(prompt + ':')
if new_val == 'x':
RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True)
elif new_val:
if is_url:
new_val = gclient_utils.UpgradeToHttps(new_val)
if new_val != initial:
RunGit(['config', 'rietveld.' + name, new_val])
SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False)
SetProperty(settings.GetDefaultPrivateFlag(),
'Private flag (rietveld only)', 'private', False)
SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL',
'tree-status-url', False)
SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True)
SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False)
SetProperty(settings.GetRunPostUploadHook(), 'Run Post Upload Hook',
'run-post-upload-hook', False)
@subcommand.usage('[repo root containing codereview.settings]')
def CMDconfig(parser, args):
"""Edits configuration for this tree."""
print('WARNING: git cl config works for Rietveld only.\n'
'For Gerrit, see http://crbug.com/579160.')
# TODO(tandrii): add Gerrit support as part of http://crbug.com/579160.
parser.add_option('--activate-update', action='store_true',
help='activate auto-updating [rietveld] section in '
'.git/config')
......@@ -1641,8 +1640,7 @@ def CMDconfig(parser, args):
return
if len(args) == 0:
GetCodereviewSettingsInteractively()
DownloadGerritHook(True)
GetRietveldCodereviewSettingsInteractively()
return 0
url = args[0]
......@@ -1651,7 +1649,6 @@ def CMDconfig(parser, args):
# Load code review settings and download hooks (if available).
LoadCodereviewSettingsFromFile(urllib2.urlopen(url))
DownloadGerritHook(True)
return 0
......
......@@ -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'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment