Search in sources :

Example 1 with RestoreInput

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);
    }
}
Also used : RestoreInput(com.google.gerrit.extensions.api.changes.RestoreInput) MoveInput(com.google.gerrit.extensions.api.changes.MoveInput) AbandonInput(com.google.gerrit.extensions.api.changes.AbandonInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput)

Aggregations

AbandonInput (com.google.gerrit.extensions.api.changes.AbandonInput)1 MoveInput (com.google.gerrit.extensions.api.changes.MoveInput)1 RestoreInput (com.google.gerrit.extensions.api.changes.RestoreInput)1 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1