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