Merge "Add MaxNoBlock category for advisory review levels"

This commit is contained in:
Shawn Pearce
2010-01-29 11:57:03 -08:00
committed by Android Code Review
3 changed files with 55 additions and 0 deletions

View File

@@ -449,6 +449,12 @@ region. This category is a `MaxWithBlock` type, which means that
the lowest negative value if present blocks a submit, while the
highest positive value is required to enable submit.
There is also a `MaxNoBlock` category which still requires the
highest positive value to submit, but the lowest negative value will
not block the change, and does not carry over between patch sets.
This level is mostly useful for automated code-reviews that may
have false-negatives that shouldn't block the change.
[NOTE]
A restart is required after making database changes.
See <<restart_changes,below>>.

View File

@@ -31,6 +31,7 @@ public abstract class CategoryFunction {
static {
all.put(SubmitFunction.NAME, new SubmitFunction());
all.put(MaxWithBlock.NAME, new MaxWithBlock());
all.put(MaxNoBlock.NAME, new MaxNoBlock());
all.put(NoOpFunction.NAME, new NoOpFunction());
}

View File

@@ -0,0 +1,48 @@
// Copyright (C) 2010 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.server.workflow;
import com.google.gerrit.common.data.ApprovalType;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.PatchSetApproval;
/**
* Computes an {@link ApprovalCategory} by looking at maximum values.
* <p>
* In order to be considered "approved" this function requires that:
* <ul>
* <li>The maximum positive value is used at least once;</li>
* <li>The user approving the maximum positive has been granted that.</li>
* </ul>
* <p>
* This function is primarily useful for advisory review fields.
*/
public class MaxNoBlock extends CategoryFunction {
public static String NAME = "MaxNoBlock";
@Override
public void run(final ApprovalType at, final FunctionState state) {
boolean passed = false;
for (final PatchSetApproval a : state.getApprovals(at)) {
state.normalize(at, a);
passed |= at.isMaxPositive(a);
}
// The type must have at least one max positive (a full accept).
//
state.valid(at, passed);
}
}