CreateChange: move out checks for "merge" field of the ChangeInput

This check is required for the input and can be done before
lots of the above code being executed. Moving it to
rejected early.

Change-Id: I62ed7b18bfa441dc6d7addb06a105069932acd9d
This commit is contained in:
Changcheng Xiao
2019-01-28 15:09:23 +01:00
parent 4a2e5eb0ec
commit de240acfb3

View File

@@ -250,10 +250,6 @@ public class CreateChange
RevCommit c;
if (input.merge != null) {
// create a merge commit
if (!(submitType.equals(SubmitType.MERGE_ALWAYS)
|| submitType.equals(SubmitType.MERGE_IF_NECESSARY))) {
throw new BadRequestException("Submit type: " + submitType + " is not supported");
}
c = newMergeCommit(git, oi, rw, projectState, mergeTip, input.merge, author, commitMessage);
} else {
// create an empty commit
@@ -342,6 +338,13 @@ public class CreateChange
me.state().getGeneralPreferences().workInProgressByDefault, false);
}
}
if (input.merge != null) {
if (!(submitType.equals(SubmitType.MERGE_ALWAYS)
|| submitType.equals(SubmitType.MERGE_IF_NECESSARY))) {
throw new BadRequestException("Submit type: " + submitType + " is not supported");
}
}
}
private void checkRequiredPermissions(Project.NameKey project, String refName)