use of com.google.gerrit.extensions.api.changes.RestoreInput in project gerrit by GerritCodeReview.
the class ReviewCommand method reviewPatchSet.
private void reviewPatchSet(PatchSet patchSet) throws Exception {
ReviewInput review = new ReviewInput();
review.message = Strings.emptyToNull(changeComment);
review.tag = Strings.emptyToNull(changeTag);
review.notify = notify;
review.labels = new TreeMap<>();
review.drafts = ReviewInput.DraftHandling.PUBLISH;
for (LabelSetter setter : optionMap.values()) {
setter.getValue().ifPresent(v -> review.labels.put(setter.getLabelName(), v));
}
review.labels.putAll(customLabels);
// We don't need to add the review comment when abandoning/restoring.
if (abandonChange || restoreChange || moveToBranch != null) {
review.message = null;
}
try {
if (abandonChange) {
AbandonInput input = new AbandonInput();
input.message = Strings.emptyToNull(changeComment);
applyReview(patchSet, review);
changeApi(patchSet).abandon(input);
} else if (restoreChange) {
RestoreInput input = new RestoreInput();
input.message = Strings.emptyToNull(changeComment);
changeApi(patchSet).restore(input);
applyReview(patchSet, review);
} else {
applyReview(patchSet, review);
}
if (moveToBranch != null) {
MoveInput moveInput = new MoveInput();
moveInput.destinationBranch = moveToBranch;
moveInput.message = Strings.emptyToNull(changeComment);
changeApi(patchSet).move(moveInput);
}
if (rebaseChange) {
revisionApi(patchSet).rebase();
}
if (submitChange) {
revisionApi(patchSet).submit();
}
} catch (IllegalStateException | RestApiException e) {
throw die(e);
}
}
Aggregations