Search in sources :

Example 1 with RebaseStatus

use of org.eclipse.che.api.git.shared.RebaseResponse.RebaseStatus in project che by eclipse.

the class JGitConnection method rebase.

@Override
public RebaseResponse rebase(String operation, String branch) throws GitException {
    RebaseResult result;
    RebaseStatus status;
    List<String> failed;
    List<String> conflicts;
    try {
        RebaseCommand rebaseCommand = getGit().rebase();
        setRebaseOperation(rebaseCommand, operation);
        if (branch != null && !branch.isEmpty()) {
            rebaseCommand.setUpstream(branch);
        }
        result = rebaseCommand.call();
    } catch (GitAPIException exception) {
        throw new GitException(exception.getMessage(), exception);
    }
    switch(result.getStatus()) {
        case ABORTED:
            status = RebaseStatus.ABORTED;
            break;
        case CONFLICTS:
            status = RebaseStatus.CONFLICTING;
            break;
        case UP_TO_DATE:
            status = RebaseStatus.ALREADY_UP_TO_DATE;
            break;
        case FAST_FORWARD:
            status = RebaseStatus.FAST_FORWARD;
            break;
        case NOTHING_TO_COMMIT:
            status = RebaseStatus.NOTHING_TO_COMMIT;
            break;
        case OK:
            status = RebaseStatus.OK;
            break;
        case STOPPED:
            status = RebaseStatus.STOPPED;
            break;
        case UNCOMMITTED_CHANGES:
            status = RebaseStatus.UNCOMMITTED_CHANGES;
            break;
        case EDIT:
            status = RebaseStatus.EDITED;
            break;
        case INTERACTIVE_PREPARED:
            status = RebaseStatus.INTERACTIVE_PREPARED;
            break;
        case STASH_APPLY_CONFLICTS:
            status = RebaseStatus.STASH_APPLY_CONFLICTS;
            break;
        default:
            status = RebaseStatus.FAILED;
    }
    conflicts = result.getConflicts() != null ? result.getConflicts() : Collections.emptyList();
    failed = result.getFailingPaths() != null ? new ArrayList<>(result.getFailingPaths().keySet()) : Collections.emptyList();
    return newDto(RebaseResponse.class).withStatus(status).withConflicts(conflicts).withFailed(failed);
}
Also used : GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RebaseResponse(org.eclipse.che.api.git.shared.RebaseResponse) RebaseCommand(org.eclipse.jgit.api.RebaseCommand) GitException(org.eclipse.che.api.git.exception.GitException) ArrayList(java.util.ArrayList) RebaseStatus(org.eclipse.che.api.git.shared.RebaseResponse.RebaseStatus) RebaseResult(org.eclipse.jgit.api.RebaseResult)

Aggregations

ArrayList (java.util.ArrayList)1 GitException (org.eclipse.che.api.git.exception.GitException)1 RebaseResponse (org.eclipse.che.api.git.shared.RebaseResponse)1 RebaseStatus (org.eclipse.che.api.git.shared.RebaseResponse.RebaseStatus)1 RebaseCommand (org.eclipse.jgit.api.RebaseCommand)1 RebaseResult (org.eclipse.jgit.api.RebaseResult)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1