Commit fc62f768 authored by Aaron Gable's avatar Aaron Gable Committed by Commit Bot

Simplify notify behavior in git-cl

Change-Id: I872658970c04cdadda2b0eaffd95e10717c09493
Reviewed-on: https://chromium-review.googlesource.com/575009Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
parent cfbb775f
......@@ -717,7 +717,7 @@ def SetReview(host, change, msg=None, labels=None, notify=None, ready=None):
body['message'] = msg
if labels:
body['labels'] = labels
if notify:
if notify is not None:
body['notify'] = 'ALL' if notify else 'NONE'
if ready:
body['ready'] = True
......
......@@ -3117,7 +3117,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
print('Adding self-LGTM (Code-Review +1) because of TBRs.')
gerrit_util.SetReview(
self._GetGerritHost(), self.GetIssue(),
labels={'Code-Review': 1}, notify=bool(options.send_mail))
msg='Self-approving for TBR', labels={'Code-Review': 1})
return 0
......@@ -3202,11 +3202,10 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
_CQState.DRY_RUN: 1,
_CQState.COMMIT: 2,
}
kwargs = {'labels': {'Commit-Queue': vote_map[new_state]}}
if new_state == _CQState.DRY_RUN:
# Don't spam everybody reviewer/owner.
kwargs['notify'] = False
gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(), **kwargs)
labels = {'Commit-Queue': vote_map[new_state]}
notify = False if new_state == _CQState.DRY_RUN else None
gerrit_util.SetReview(self._GetGerritHost(), self.GetIssue(),
labels=labels, notify=notify)
def CannotTriggerTryJobReason(self):
try:
......
......@@ -623,8 +623,8 @@ class TestGitCl(TestCase):
lambda h, i, reviewers, ccs, notify: self._mocked_call(
'AddReviewers', h, i, reviewers, ccs, notify))
self.mock(git_cl.gerrit_util, 'SetReview',
lambda h, i, labels, notify: self._mocked_call(
'SetReview', h, i, labels, notify))
lambda h, i, msg=None, labels=None, notify=None:
self._mocked_call('SetReview', h, i, msg, labels, notify))
self.mock(git_cl.gerrit_util.GceAuthenticator, 'is_gce',
classmethod(lambda _: False))
self.mock(git_cl, 'DieWithError',
......@@ -1605,7 +1605,8 @@ class TestGitCl(TestCase):
if tbr:
calls += [
(('SetReview', 'chromium-review.googlesource.com',
123456 if squash else None, {'Code-Review': 1}, notify), ''),
123456 if squash else None, 'Self-approving for TBR',
{'Code-Review': 1}, None), ''),
]
calls += cls._git_post_upload_calls()
return 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