Commit 8acd833e authored by tandrii@chromium.org's avatar tandrii@chromium.org

Gerrit git cl upload: implement setting cc and reviewers.

R=machenbach@chromium.org,andybons@chromium.org
BUG=323819

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299887 0039d316-1c4b-4281-b951-d872f2087c98
parent bf766ba3
...@@ -2392,35 +2392,27 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase): ...@@ -2392,35 +2392,27 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
print('WARNING: underscores in title will be converted to spaces.') print('WARNING: underscores in title will be converted to spaces.')
refspec_opts.append('m=' + options.title.replace(' ', '_')) refspec_opts.append('m=' + options.title.replace(' ', '_'))
receive_options = []
cc = self.GetCCList().split(',') cc = self.GetCCList().split(',')
if options.cc: if options.cc:
cc.extend(options.cc) cc.extend(options.cc)
cc = filter(None, cc) cc = filter(None, cc)
if cc: if cc:
receive_options += ['--cc=' + email for email in cc] refspec_opts.extend('cc=' + email.strip() for email in cc)
if change_desc.get_reviewers(): if change_desc.get_reviewers():
receive_options.extend( refspec_opts.extend('r=' + email.strip()
'--reviewer=' + email for email in change_desc.get_reviewers()) for email in change_desc.get_reviewers())
git_command = ['git', 'push']
if receive_options:
# TODO(tandrii): clean this up in follow up. This doesn't work, as it gets
# totally ignored by Gerrit.
git_command.append('--receive-pack=git receive-pack %s' %
' '.join(receive_options))
refspec_suffix = '' refspec_suffix = ''
if refspec_opts: if refspec_opts:
refspec_suffix = '%' + ','.join(refspec_opts) refspec_suffix = '%' + ','.join(refspec_opts)
assert ' ' not in refspec_suffix, ( assert ' ' not in refspec_suffix, (
'spaces not allowed in refspec: "%s"' % refspec_suffix) 'spaces not allowed in refspec: "%s"' % refspec_suffix)
refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix) refspec = '%s:refs/for/%s%s' % (ref_to_push, branch, refspec_suffix)
git_command += [gerrit_remote, refspec]
push_stdout = gclient_utils.CheckCallAndFilter( push_stdout = gclient_utils.CheckCallAndFilter(
git_command, ['git', 'push', gerrit_remote, refspec],
print_stdout=True, print_stdout=True,
# Flush after every line: useful for seeing progress when running as # Flush after every line: useful for seeing progress when running as
# recipe. # recipe.
......
...@@ -801,16 +801,16 @@ class TestGitCl(TestCase): ...@@ -801,16 +801,16 @@ class TestGitCl(TestCase):
expected_upstream_ref + '..' + ref_to_push],), ''), expected_upstream_ref + '..' + ref_to_push],), ''),
((['git', 'config', 'rietveld.cc'],), '') ((['git', 'config', 'rietveld.cc'],), '')
] ]
receive_pack = '--receive-pack=git receive-pack ' # Add cc from watch list.
receive_pack += '--cc=joe@example.com' # from watch list if ref_suffix == '':
ref_suffix = '%cc=joe@example.com'
else:
ref_suffix += ',cc=joe@example.com'
if reviewers: if reviewers:
receive_pack += ' ' ref_suffix += ',' + ','.join('r=%s' % email
receive_pack += ' '.join( for email in sorted(reviewers))
'--reviewer=' + email for email in sorted(reviewers))
receive_pack += ''
calls += [ calls += [
((['git', ((['git', 'push', 'origin',
'push', receive_pack, 'origin',
ref_to_push + ':refs/for/refs/heads/master' + ref_suffix],), ref_to_push + ':refs/for/refs/heads/master' + ref_suffix],),
('remote:\n' ('remote:\n'
'remote: Processing changes: (\)\n' 'remote: Processing changes: (\)\n'
......
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