Add users mentioned in commit footer as reviewers on draft publish
If a user is mentioned in a footer of a commit message (e.g. by a 'Signed-off-by') then this user is added as reviewer to this change/patchset. This is important because the mentioned user may want to check that he is correctly referenced. If a draft change/patchset is uploaded the users mentioned in the footers cannot be added as reviewers because this would make the draft visible to them. But they should be added as reviewers when the draft is published since the change/patchset is now visible to them. Change-Id: I1fa77460eae25b48a3cab4e4535f1508146fea11 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
committed by
Gerrit Code Review
parent
be46e51a20
commit
be59d97cad
@@ -15,6 +15,7 @@
|
||||
|
||||
package com.google.gerrit.server.changedetail;
|
||||
|
||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromApprovals;
|
||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
||||
|
||||
import com.google.gerrit.common.ChangeHooks;
|
||||
@@ -23,6 +24,7 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetInfo;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
@@ -51,6 +53,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@@ -67,6 +70,7 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
private final ChangeHooks hooks;
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final PatchSetInfoFactory patchSetInfoFactory;
|
||||
private final ApprovalsUtil approvalsUtil;
|
||||
private final AccountResolver accountResolver;
|
||||
private final CreateChangeSender.Factory createChangeSenderFactory;
|
||||
private final ReplacePatchSetSender.Factory replacePatchSetFactory;
|
||||
@@ -88,6 +92,7 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
this.hooks = hooks;
|
||||
this.repoManager = repoManager;
|
||||
this.patchSetInfoFactory = patchSetInfoFactory;
|
||||
this.approvalsUtil = approvalsUtil;
|
||||
this.accountResolver = accountResolver;
|
||||
this.createChangeSenderFactory = createChangeSenderFactory;
|
||||
this.replacePatchSetFactory = replacePatchSetFactory;
|
||||
@@ -170,6 +175,8 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
recipients.remove(me);
|
||||
|
||||
if (newChange) {
|
||||
approvalsUtil.addReviewers(db, updatedChange, updatedPatchSet, info,
|
||||
recipients.getReviewers(), Collections.<Account.Id> emptySet());
|
||||
try {
|
||||
CreateChangeSender cm = createChangeSenderFactory.create(updatedChange);
|
||||
cm.setFrom(me);
|
||||
@@ -181,6 +188,12 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
log.error("Cannot send email for new change " + updatedChange.getId(), e);
|
||||
}
|
||||
} else {
|
||||
final List<PatchSetApproval> patchSetApprovals =
|
||||
db.patchSetApprovals().byChange(updatedChange.getId()).toList();
|
||||
final MailRecipients oldRecipients =
|
||||
getRecipientsFromApprovals(patchSetApprovals);
|
||||
approvalsUtil.addReviewers(db, updatedChange, updatedPatchSet, info,
|
||||
recipients.getReviewers(), oldRecipients.getAll());
|
||||
final ChangeMessage msg =
|
||||
new ChangeMessage(new ChangeMessage.Key(updatedChange.getId(),
|
||||
ChangeUtil.messageUUID(db)), me,
|
||||
|
||||
Reference in New Issue
Block a user