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>
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
|
||||
/**
|
||||
* Stable identifier for options passed to a particular submit rule evaluator.
|
||||
@@ -26,12 +25,7 @@ import com.google.gerrit.common.Nullable;
|
||||
@AutoValue
|
||||
public abstract class SubmitRuleOptions {
|
||||
private static final SubmitRuleOptions defaults =
|
||||
new AutoValue_SubmitRuleOptions.Builder()
|
||||
.allowClosed(false)
|
||||
.skipFilters(false)
|
||||
.logErrors(true)
|
||||
.rule(null)
|
||||
.build();
|
||||
new AutoValue_SubmitRuleOptions.Builder().allowClosed(false).build();
|
||||
|
||||
public static SubmitRuleOptions defaults() {
|
||||
return defaults;
|
||||
@@ -43,25 +37,12 @@ public abstract class SubmitRuleOptions {
|
||||
|
||||
public abstract boolean allowClosed();
|
||||
|
||||
public abstract boolean skipFilters();
|
||||
|
||||
public abstract boolean logErrors();
|
||||
|
||||
@Nullable
|
||||
public abstract String rule();
|
||||
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
public abstract SubmitRuleOptions.Builder allowClosed(boolean allowClosed);
|
||||
|
||||
public abstract SubmitRuleOptions.Builder skipFilters(boolean skipFilters);
|
||||
|
||||
public abstract SubmitRuleOptions.Builder rule(@Nullable String rule);
|
||||
|
||||
public abstract SubmitRuleOptions.Builder logErrors(boolean logErrors);
|
||||
|
||||
public abstract SubmitRuleOptions build();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user