Do not delete users' draft comments

Gerrit's "Set Review" API has a built-in trap:

 drafts (optional)
	How draft comments are handled that are already in the
	database but that were not also described in this input.

	Allowed values are DELETE, PUBLISH, PUBLISH_ALL_REVISIONS and
	KEEP. All values except PUBLISH_ALL_REVISIONS operate only on
	drafts for a single revision.

	If not set, the default is DELETE.

That destructive default is almost never what a person wants.  Use
KEEP instead.

Noticed because "git cl try" was losing people's comments.

Bug: gerrit:6812
Change-Id: I1d09231ea23b13c925d301241bef266df2ddf1cf
Reviewed-on: https://chromium-review.googlesource.com/764488
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Jonathan Nieder <jrn@google.com>
changes/88/764488/2
Jonathan Nieder 8 years ago committed by Commit Bot
parent f2d1615bc8
commit 1ea21322e3

@ -665,6 +665,7 @@ def AddReviewers(host, change, reviewers=None, ccs=None, notify=True,
path = 'changes/%s/revisions/current/review' % change
body = {
'drafts': 'KEEP',
'reviewers': [],
'notify': 'ALL' if notify else 'NONE',
}
@ -718,7 +719,7 @@ def SetReview(host, change, msg=None, labels=None, notify=None, ready=None):
if not msg and not labels:
return
path = 'changes/%s/revisions/current/review' % change
body = {}
body = {'drafts': 'KEEP'}
if msg:
body['message'] = msg
if labels:
@ -760,6 +761,7 @@ def ResetReviewLabels(host, change, label, value='0', message=None,
for review in jmsg.get('labels', {}).get(label, {}).get('all', []):
if str(review.get('value', value)) != value:
body = {
'drafts': 'KEEP',
'message': message,
'labels': {label: value},
'on_behalf_of': review['_account_id'],

Loading…
Cancel
Save