diff --git a/gerrit_util.py b/gerrit_util.py index 1756a1300..7afe96b44 100755 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -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 diff --git a/git_cl.py b/git_cl.py index 2933b0054..2c4b4bf12 100755 --- a/git_cl.py +++ b/git_cl.py @@ -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: diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 17edd8fb3..52ee43b6f 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -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