Search in sources :

Example 1 with StashApplyStatus

use of com.oxygenxml.git.view.stash.StashApplyStatus in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method applyStash.

/**
 * Apply the given stash.
 *
 * @param stashRef the stash which will be applied.
 *
 * @return the status for stash apply operation.
 *
 * @throws GitAPIException
 */
public StashApplyStatus applyStash(String stashRef) throws GitAPIException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_APPLY));
    StashApplyStatus status = StashApplyStatus.NOT_APPLIED_UNKNOWN_CAUSE;
    try {
        checkIfStashIsApplicable(stashRef);
        git.stashApply().setStashRef(stashRef).call();
        status = StashApplyStatus.APPLIED_SUCCESSFULLY;
        fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.STASH_APPLY));
    } catch (StashApplyFailureWithStatusException e) {
        status = e.getStatus();
        displayStashApplyFailedCauseMessage(false, status, e);
    } catch (StashApplyFailureException | IOException e) {
        displayStashApplyFailedCauseMessage(false, status, e);
    }
    return status;
}
Also used : GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo) StashApplyStatus(com.oxygenxml.git.view.stash.StashApplyStatus) StashApplyFailureWithStatusException(com.oxygenxml.git.view.stash.StashApplyFailureWithStatusException) StashApplyFailureException(org.eclipse.jgit.api.errors.StashApplyFailureException) IOException(java.io.IOException)

Example 2 with StashApplyStatus

use of com.oxygenxml.git.view.stash.StashApplyStatus in project oxygen-git-client-addon by oxygenxml.

the class GitAccess method popStash.

/**
 * Pop the given stash.
 *
 * @param stashRef the stash which will be applied.
 *
 * @return the status for stash apply operation.
 *
 * @throws GitAPIException
 */
public StashApplyStatus popStash(String stashRef) throws GitAPIException {
    fireOperationAboutToStart(new GitEventInfo(GitOperation.STASH_APPLY));
    StashApplyStatus status = StashApplyStatus.NOT_APPLIED_UNKNOWN_CAUSE;
    try {
        checkIfStashIsApplicable(stashRef);
        git.stashApply().setStashRef(stashRef).call();
        List<RevCommit> stashes = new ArrayList<>(listStashes());
        status = StashApplyStatus.APPLIED_SUCCESSFULLY;
        for (int i = 0; i < stashes.size(); i++) {
            if (stashRef.equals(stashes.get(i).getName())) {
                dropStash(i);
                break;
            }
        }
        fireOperationSuccessfullyEnded(new GitEventInfo(GitOperation.STASH_APPLY));
    } catch (StashApplyFailureWithStatusException e) {
        status = e.getStatus();
        displayStashApplyFailedCauseMessage(true, status, e);
    } catch (StashApplyFailureException | IOException e) {
        displayStashApplyFailedCauseMessage(true, status, e);
    }
    return status;
}
Also used : GitEventInfo(com.oxygenxml.git.view.event.GitEventInfo) BranchGitEventInfo(com.oxygenxml.git.view.event.BranchGitEventInfo) FileGitEventInfo(com.oxygenxml.git.view.event.FileGitEventInfo) WorkingCopyGitEventInfo(com.oxygenxml.git.view.event.WorkingCopyGitEventInfo) StashApplyStatus(com.oxygenxml.git.view.stash.StashApplyStatus) StashApplyFailureWithStatusException(com.oxygenxml.git.view.stash.StashApplyFailureWithStatusException) ArrayList(java.util.ArrayList) StashApplyFailureException(org.eclipse.jgit.api.errors.StashApplyFailureException) IOException(java.io.IOException) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

BranchGitEventInfo (com.oxygenxml.git.view.event.BranchGitEventInfo)2 FileGitEventInfo (com.oxygenxml.git.view.event.FileGitEventInfo)2 GitEventInfo (com.oxygenxml.git.view.event.GitEventInfo)2 WorkingCopyGitEventInfo (com.oxygenxml.git.view.event.WorkingCopyGitEventInfo)2 StashApplyFailureWithStatusException (com.oxygenxml.git.view.stash.StashApplyFailureWithStatusException)2 StashApplyStatus (com.oxygenxml.git.view.stash.StashApplyStatus)2 IOException (java.io.IOException)2 StashApplyFailureException (org.eclipse.jgit.api.errors.StashApplyFailureException)2 ArrayList (java.util.ArrayList)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1