Line data Source code
1 : // Copyright (C) 2012 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.git.validators; 16 : 17 : import com.google.gerrit.extensions.annotations.ExtensionPoint; 18 : import com.google.gerrit.server.events.CommitReceivedEvent; 19 : import java.util.List; 20 : 21 : /** 22 : * Listener to provide validation on received commits. 23 : * 24 : * <p>Invoked by Gerrit when a new commit is received, has passed basic Gerrit validation and can be 25 : * then subject to extra validation checks. 26 : */ 27 : @ExtensionPoint 28 : public interface CommitValidationListener { 29 : /** 30 : * Commit validation. 31 : * 32 : * @param receiveEvent commit event details 33 : * @return list of validation messages 34 : * @throws CommitValidationException if validation fails 35 : */ 36 : List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) 37 : throws CommitValidationException; 38 : 39 : /** 40 : * Whether this validator should validate all commits. 41 : * 42 : * @return {@code true} if this validator should validate all commits, even when the {@code 43 : * skip-validation} push option was specified. 44 : */ 45 : default boolean shouldValidateAllCommits() { 46 3 : return false; 47 : } 48 : }