SubmitRuleEvaluator: rename canSubmit() to evaluate()
Change-Id: I9573d6db0e6064dfa645f211e0e16e8f3a45cbf4
This commit is contained in:
@@ -434,7 +434,7 @@ public class ChangeJson {
|
|||||||
cd.setSubmitRecords(new SubmitRuleEvaluator(cd).setPatchSet(ps)
|
cd.setSubmitRecords(new SubmitRuleEvaluator(cd).setPatchSet(ps)
|
||||||
.setFastEvalLabels(true)
|
.setFastEvalLabels(true)
|
||||||
.setAllowDraft(true)
|
.setAllowDraft(true)
|
||||||
.canSubmit());
|
.evaluate());
|
||||||
return cd.getSubmitRecords();
|
return cd.getSubmitRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@ public class ReviewerJson {
|
|||||||
.setPatchSet(ps)
|
.setPatchSet(ps)
|
||||||
.setFastEvalLabels(true)
|
.setFastEvalLabels(true)
|
||||||
.setAllowDraft(true)
|
.setAllowDraft(true)
|
||||||
.canSubmit()) {
|
.evaluate()) {
|
||||||
if (rec.labels == null) {
|
if (rec.labels == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -543,7 +543,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
|||||||
throws ResourceConflictException, OrmException {
|
throws ResourceConflictException, OrmException {
|
||||||
List<SubmitRecord> results = new SubmitRuleEvaluator(cd)
|
List<SubmitRecord> results = new SubmitRuleEvaluator(cd)
|
||||||
.setPatchSet(patchSet)
|
.setPatchSet(patchSet)
|
||||||
.canSubmit();
|
.evaluate();
|
||||||
Optional<SubmitRecord> ok = findOkRecord(results);
|
Optional<SubmitRecord> ok = findOkRecord(results);
|
||||||
if (ok.isPresent()) {
|
if (ok.isPresent()) {
|
||||||
// Rules supplied a valid solution.
|
// Rules supplied a valid solution.
|
||||||
@@ -552,7 +552,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
|||||||
return results;
|
return results;
|
||||||
} else if (results.isEmpty()) {
|
} else if (results.isEmpty()) {
|
||||||
throw new IllegalStateException(String.format(
|
throw new IllegalStateException(String.format(
|
||||||
"ChangeControl.canSubmit returned empty list for %s in %s",
|
"SubmitRuleEvaluator.evaluate returned empty list for %s in %s",
|
||||||
patchSet.getId(),
|
patchSet.getId(),
|
||||||
cd.change().getProject().get()));
|
cd.change().getProject().get()));
|
||||||
}
|
}
|
||||||
|
@@ -85,7 +85,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
|
|||||||
.setLogErrors(false)
|
.setLogErrors(false)
|
||||||
.setSkipSubmitFilters(input.filters == Filters.SKIP)
|
.setSkipSubmitFilters(input.filters == Filters.SKIP)
|
||||||
.setRule(input.rule)
|
.setRule(input.rule)
|
||||||
.canSubmit();
|
.evaluate();
|
||||||
List<Record> out = Lists.newArrayListWithCapacity(records.size());
|
List<Record> out = Lists.newArrayListWithCapacity(records.size());
|
||||||
AccountLoader accounts = accountInfoFactory.create(true);
|
AccountLoader accounts = accountInfoFactory.create(true);
|
||||||
for (SubmitRecord r : records) {
|
for (SubmitRecord r : records) {
|
||||||
|
@@ -118,7 +118,7 @@ public class SubmitRuleEvaluator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ps patch set of the change to evaluate. If not set, the current
|
* @param ps patch set of the change to evaluate. If not set, the current
|
||||||
* patch set will be loaded from {@link #canSubmit()} or {@link
|
* patch set will be loaded from {@link #evaluate()} or {@link
|
||||||
* #getSubmitType}.
|
* #getSubmitType}.
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
@@ -140,7 +140,7 @@ public class SubmitRuleEvaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param allow whether to allow {@link #canSubmit()} on closed changes.
|
* @param allow whether to allow {@link #evaluate()} on closed changes.
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public SubmitRuleEvaluator setAllowClosed(boolean allow) {
|
public SubmitRuleEvaluator setAllowClosed(boolean allow) {
|
||||||
@@ -149,7 +149,7 @@ public class SubmitRuleEvaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param allow whether to allow {@link #canSubmit()} on closed changes.
|
* @param allow whether to allow {@link #evaluate()} on draft changes.
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public SubmitRuleEvaluator setAllowDraft(boolean allow) {
|
public SubmitRuleEvaluator setAllowDraft(boolean allow) {
|
||||||
@@ -195,7 +195,7 @@ public class SubmitRuleEvaluator {
|
|||||||
* @return List of {@link SubmitRecord} objects returned from the evaluated
|
* @return List of {@link SubmitRecord} objects returned from the evaluated
|
||||||
* rules, including any errors.
|
* rules, including any errors.
|
||||||
*/
|
*/
|
||||||
public List<SubmitRecord> canSubmit() {
|
public List<SubmitRecord> evaluate() {
|
||||||
try {
|
try {
|
||||||
initPatchSet();
|
initPatchSet();
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
|
@@ -200,7 +200,7 @@ public class OutputStreamQuery {
|
|||||||
eventFactory.addSubmitRecords(c, new SubmitRuleEvaluator(d)
|
eventFactory.addSubmitRecords(c, new SubmitRuleEvaluator(d)
|
||||||
.setAllowClosed(true)
|
.setAllowClosed(true)
|
||||||
.setAllowDraft(true)
|
.setAllowDraft(true)
|
||||||
.canSubmit());
|
.evaluate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeCommitMessage) {
|
if (includeCommitMessage) {
|
||||||
|
Reference in New Issue
Block a user