Files
gerrit/java/com/google/gerrit/server/project/SubmitRuleOptions.java
Edwin Kempin 5c13722d00 SubmitRule: Remove SubmitRuleOptions arg from evaluate method
The SubmitRuleOptions contain mostly Prolog-specific settings and are
only used by the PrologRule. All other implementation of SubmitRule
ignore the options, hence the interface is cleaner without the
SubmitRuleOptions arg.

All Prolog-specific settings from SubmitRuleOptions are now moved into a
new PrologOptions AutoValue class that is only used by PrologRule and
PrologRuleEvaluator. There are only 2 variants of the prolog options
that are used, one for checking the submittability of changes against
the Prolog rules that are configured in the project, one for testing
Prolog rules that are passed in into the TestSubmitRule / TestSubmitType
REST endpoints. For the first case we go through SubmitRuleEvaluator. In
this case we pass no options to PrologRule, but PrologRule just uses the
default options which work for production. For the second case we invoke
PrologRule directly and pass in the dry run options.

SubmitRuleOptions contains only a single option now (allowClosed), but
this options is checked before submit rules are invoked. Hence this
option is not relevant for SubmitRule implementations.

The SubmitRuleOptions that are used for computing submit records that
are stored in the change index (SUBMIT_RULE_OPTIONS_LENIENT and
SUBMIT_RULE_OPTIONS_STRICT) are not changed since they only use the one
field in SubmitRuleOptions that is still there (allowClosed).

Change-Id: Ifa474e2c16fee02f52b6e6339bdf980b8f4f3a50
Signed-off-by: Edwin Kempin <ekempin@google.com>
2019-08-12 09:21:53 +02:00

49 lines
1.5 KiB
Java

// Copyright (C) 2016 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.project;
import com.google.auto.value.AutoValue;
/**
* Stable identifier for options passed to a particular submit rule evaluator.
*
* <p>Used to test whether it is ok to reuse a cached list of submit records. Does not include a
* change or patch set ID; callers are responsible for checking those on their own.
*/
@AutoValue
public abstract class SubmitRuleOptions {
private static final SubmitRuleOptions defaults =
new AutoValue_SubmitRuleOptions.Builder().allowClosed(false).build();
public static SubmitRuleOptions defaults() {
return defaults;
}
public static Builder builder() {
return defaults.toBuilder();
}
public abstract boolean allowClosed();
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract SubmitRuleOptions.Builder allowClosed(boolean allowClosed);
public abstract SubmitRuleOptions build();
}
}