use of com.google.gerrit.extensions.api.changes.AbandonInput in project gerrit by GerritCodeReview.
the class ReviewCommand method reviewPatchSet.
private void reviewPatchSet(final PatchSet patchSet) throws Exception {
if (notify == null) {
notify = NotifyHandling.ALL;
}
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;
review.strictLabels = strictLabels;
for (ApproveOption ao : optionList) {
Short v = ao.value();
if (v != null) {
review.labels.put(ao.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();
}
if (publishPatchSet) {
revisionApi(patchSet).publish();
} else if (deleteDraftPatchSet) {
revisionApi(patchSet).delete();
}
} catch (IllegalStateException | RestApiException e) {
throw die(e);
}
}
Aggregations