Commit 35747409 authored by rmistry's avatar rmistry Committed by Commit bot

Add CC_LIST and --cc to Gerrit issues via API to be similar to CCs in Rietveld

BUG=chromium:649660

Review-Url: https://codereview.chromium.org/2378703002
parent 3e1cde7a
......@@ -613,7 +613,7 @@ def GetReview(host, change, revision):
return ReadHttpJsonResponse(CreateHttpConn(host, path))
def AddReviewers(host, change, add=None):
def AddReviewers(host, change, add=None, is_reviewer=True):
"""Add reviewers to a change."""
if not add:
return
......@@ -621,7 +621,10 @@ def AddReviewers(host, change, add=None):
add = (add,)
path = 'changes/%s/reviewers' % change
for r in add:
body = {'reviewer': r}
body = {
'reviewer': r,
'state': 'REVIEWER' if is_reviewer else 'CC',
}
conn = CreateHttpConn(host, path, reqtype='POST', body=body)
jmsg = ReadHttpJsonResponse(conn, ignore_404=False)
return jmsg
......
......@@ -2618,13 +2618,6 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
else:
refspec_opts.append('notify=NONE')
cc = self.GetCCList().split(',')
if options.cc:
cc.extend(options.cc)
cc = filter(None, cc)
if cc:
refspec_opts.extend('cc=' + email.strip() for email in cc)
reviewers = change_desc.get_reviewers()
if reviewers:
refspec_opts.extend('r=' + email.strip() for email in reviewers)
......@@ -2662,6 +2655,16 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
'Change-Id: %s') % (len(change_numbers), change_id))
self.SetIssue(change_numbers[0])
self._GitSetBranchConfigValue('gerritsquashhash', ref_to_push)
# Add cc's from the CC_LIST and --cc flag (if any).
cc = self.GetCCList().split(',')
if options.cc:
cc.extend(options.cc)
cc = filter(None, cc)
if cc:
gerrit_util.AddReviewers(
self._GetGerritHost(), self.GetIssue(), cc, is_reviewer=False)
return 0
def _AddChangeIdToCommitMessage(self, options, args):
......
......@@ -884,7 +884,6 @@ class TestGitCl(TestCase):
calls += [
((['git', 'rev-list',
expected_upstream_ref + '..' + ref_to_push],), ''),
((['git', 'config', 'rietveld.cc'],), '')
]
notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
......@@ -893,9 +892,6 @@ class TestGitCl(TestCase):
else:
ref_suffix = '%' + notify_suffix
# Add cc from watch list.
ref_suffix += ',cc=joe@example.com'
if reviewers:
ref_suffix += ',' + ','.join('r=%s' % email
for email in sorted(reviewers))
......@@ -925,6 +921,12 @@ class TestGitCl(TestCase):
((['git', 'config', 'branch.master.gerritsquashhash',
'abcdef0123456789'],), ''),
]
calls += [
((['git', 'config', 'rietveld.cc'],), ''),
((['AddReviewers', 'chromium-review.googlesource.com',
123456 if squash else None,
['joe@example.com'], False],), ''),
]
calls += cls._git_post_upload_calls()
return calls
......@@ -958,6 +960,9 @@ class TestGitCl(TestCase):
self.mock(git_cl.gclient_utils, 'RunEditor',
lambda *_, **__: self._mocked_call(['RunEditor']))
self.mock(git_cl, 'DownloadGerritHook', self._mocked_call)
self.mock(git_cl.gerrit_util, 'AddReviewers',
lambda h, i, add, is_reviewer: self._mocked_call(
['AddReviewers', h, i, add, is_reviewer]))
self.calls = self._gerrit_base_calls(issue=issue)
self.calls += self._gerrit_upload_calls(
......
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