Update CommentValidator interface to include change context
Include the project and change number when calling to validate comments so that validators can use that data to determine if they should run validation for that comment. Bug: Issue 12055 Change-Id: I99bb99350b08e9527e9e4b0da53eb8c8d14a3340
This commit is contained in:
@@ -93,6 +93,7 @@ import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.extensions.validators.CommentForValidation;
|
||||
import com.google.gerrit.extensions.validators.CommentForValidation.CommentType;
|
||||
import com.google.gerrit.extensions.validators.CommentValidationContext;
|
||||
import com.google.gerrit.extensions.validators.CommentValidationFailure;
|
||||
import com.google.gerrit.extensions.validators.CommentValidator;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
@@ -2014,8 +2015,13 @@ class ReceiveCommits {
|
||||
: CommentType.FILE_COMMENT,
|
||||
comment.message))
|
||||
.collect(toImmutableList());
|
||||
CommentValidationContext ctx =
|
||||
CommentValidationContext.builder()
|
||||
.changeId(change.getChangeId())
|
||||
.project(change.getProject().get())
|
||||
.build();
|
||||
ImmutableList<CommentValidationFailure> commentValidationFailures =
|
||||
PublishCommentUtil.findInvalidComments(commentValidators, draftsForValidation);
|
||||
PublishCommentUtil.findInvalidComments(ctx, commentValidators, draftsForValidation);
|
||||
magicBranch.setCommentsValid(commentValidationFailures.isEmpty());
|
||||
commentValidationFailures.forEach(
|
||||
failure ->
|
||||
@@ -3337,7 +3343,8 @@ class ReceiveCommits {
|
||||
}
|
||||
|
||||
logger.atFine().log(
|
||||
"Auto-closing %d changes with existing patch sets and %d with new patch sets",
|
||||
"Auto-closing %d changes with existing patch sets and %d with new patch"
|
||||
+ " sets",
|
||||
existingPatchSets, newPatchSets);
|
||||
bu.execute();
|
||||
} catch (IOException | StorageException | PermissionBackendException e) {
|
||||
|
||||
Reference in New Issue
Block a user