Add extension point for plugins to validate comments before publishing
This allows to prevent publication of comments that fail validation. This change includes only the validator interface. There are three ways to publish comments: A) On posting the review draft comments are read and, possibly together with new comments included in the PostReview request, published. B) Running "git push" when the "Publish comments on push" user option is enabled (code in ReceiveCommits). C) Via email (code in MailProcessor). Subsequent changes will add the actual validation calls. Before plugins can use this interface with a reasonable UX, the UI needs to handle the new error in PostReview. Until then the UI will show an error message that does not indicate the comment validation failure. Change-Id: Icd1a206dc6468a2e9b08cf3a39de9860bc879c4b
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2019 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.validators;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||
|
||||
/**
|
||||
* Validates review comments and messages. Rejecting any comment/message will prevent all comments
|
||||
* from being published.
|
||||
*/
|
||||
@ExtensionPoint
|
||||
public interface CommentValidator {
|
||||
|
||||
/**
|
||||
* Validate the specified commits.
|
||||
*
|
||||
* @return An empty list if all commits are valid, or else a list of validation failures.
|
||||
*/
|
||||
ImmutableList<CommentValidationFailure> validateComments(
|
||||
ImmutableList<CommentForValidation> comments);
|
||||
}
|
||||
Reference in New Issue
Block a user