Merge "Handle error when publishing non draft patch set"
This commit is contained in:
@@ -67,7 +67,10 @@ public class ReviewResult {
|
||||
PUBLISH_NOT_PERMITTED,
|
||||
|
||||
/** Review operation not permitted by rule. */
|
||||
RULE_ERROR
|
||||
RULE_ERROR,
|
||||
|
||||
/** Review operation invalid because patch set is not a draft. */
|
||||
NOT_A_DRAFT,
|
||||
}
|
||||
|
||||
protected Type type;
|
||||
|
@@ -57,9 +57,14 @@ public class PublishDraft implements Callable<ReviewResult> {
|
||||
result.setChangeId(changeId);
|
||||
final ChangeControl control = changeControlFactory.validateFor(changeId);
|
||||
final PatchSet patch = db.patchSets().get(patchSetId);
|
||||
if (patch == null || !patch.isDraft()) {
|
||||
if (patch == null) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
}
|
||||
if (!patch.isDraft()) {
|
||||
result.addError(new ReviewResult.Error(
|
||||
ReviewResult.Error.Type.NOT_A_DRAFT));
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!control.canPublish(db)) {
|
||||
result.addError(new ReviewResult.Error(
|
||||
|
@@ -294,6 +294,9 @@ public class ReviewCommand extends BaseCommand {
|
||||
case RULE_ERROR:
|
||||
errMsg += "rule error";
|
||||
break;
|
||||
case NOT_A_DRAFT:
|
||||
errMsg += "change is not a draft";
|
||||
break;
|
||||
default:
|
||||
errMsg += "failure in review";
|
||||
}
|
||||
|
Reference in New Issue
Block a user