Add change owner as reviewer if labels were applied during push

If the owner is not added as a reviewer, deleting their label will not
be possible.

Change-Id: I1b8b5312b34a0bf9295b4bdacda7b97bce7d0708
This commit is contained in:
Patrick Hiesel
2017-02-27 14:22:35 +01:00
parent d5c21d9931
commit 302b59c491
3 changed files with 60 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.git;
import static com.google.gerrit.common.FooterConstants.CHANGE_ID;
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromReviewers;
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
@@ -280,6 +281,14 @@ public class ReplaceOp extends BatchUpdate.Op {
info,
recipients.getReviewers(),
oldRecipients.getAll());
// Check if approvals are changing in with this update. If so, add current user to reviewers.
// Note that this is done separately as addReviewers is filtering out the change owner as
// reviewer which is needed in several other code paths.
if (magicBranch != null && !magicBranch.labels.isEmpty()) {
update.putReviewer(ctx.getAccountId(), REVIEWER);
}
recipients.add(oldRecipients);
String approvalMessage =