Commit 0d6b46e3 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

git cl comment: require explicit --codereview with -i|--issue flag.

R=agable@chromium.org,machenbach@chromium.org
BUG=698236

Change-Id: If79f938e457f176c47badd75f78ed4ecb764ec2d
Reviewed-on: https://chromium-review.googlesource.com/456700
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent 0bbe6fa0
......@@ -4260,8 +4260,9 @@ def CMDcomments(parser, args):
"""Shows or posts review comments for any changelist."""
parser.add_option('-a', '--add-comment', dest='comment',
help='comment to add to an issue')
parser.add_option('-i', dest='issue',
help='review issue id (defaults to current issue)')
parser.add_option('-i', '--issue', dest='issue',
help='review issue id (defaults to current issue). '
'If given, requires --rietveld or --gerrit')
parser.add_option('-j', '--json-file',
help='File to write JSON summary to')
auth.add_auth_options(parser)
......@@ -4276,6 +4277,8 @@ def CMDcomments(parser, args):
issue = int(options.issue)
except ValueError:
DieWithError('A review issue id is expected to be a number')
if not options.forced_codereview:
parser.error('--gerrit or --rietveld is required if --issue is specified')
cl = Changelist(issue=issue,
# TODO(tandrii): remove 'rietveld' default.
......
......@@ -3090,7 +3090,7 @@ class TestGitCl(TestCase):
sys.stdout.getvalue(),
'However, your configured .gitcookies file is missing.')
def test_git_cl_comment_add_default(self):
def test_git_cl_comment_add_rietveld(self):
self.mock(git_cl._RietveldChangelistImpl, 'AddComment',
lambda _, message: self._mocked_call('AddComment', message))
self.calls = [
......@@ -3098,8 +3098,8 @@ class TestGitCl(TestCase):
((['git', 'config', 'rietveld.server'],), 'codereview.chromium.org'),
(('AddComment', 'msg'), ''),
]
# TODO(tandrii): --rietveld should be specified here.
self.assertEqual(0, git_cl.main(['comment', '-i', '10', '-a', 'msg']))
self.assertEqual(0, git_cl.main(['comment', '--rietveld',
'-i', '10', '-a', 'msg']))
def test_git_cl_comment_add_gerrit(self):
self.mock(git_cl.gerrit_util, 'SetReview',
......
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