Example usage for org.eclipse.jgit.transport RemoteRefUpdate.Status toString

List of usage examples for org.eclipse.jgit.transport RemoteRefUpdate.Status toString

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport RemoteRefUpdate.Status toString.

Prototype

@SuppressWarnings("nls")
@Override
public String toString() 

Source Link

Usage

From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java

License:Open Source License

private void push() throws CoreException {
    try {/*from   w  ww  . ja  va2 s  . co  m*/
        Repository local = getLocalRepo();
        Git git = new Git(local);

        PushCommand push = git.push();
        push.setRefSpecs(new RefSpec("refs/heads/*:refs/heads/*"));
        push.setCredentialsProvider(getCredentialsProvider());

        Iterable<PushResult> pushResults = push.call();

        for (PushResult pushResult : pushResults) {
            Collection<RemoteRefUpdate> updates = pushResult.getRemoteUpdates();
            for (RemoteRefUpdate update : updates) {
                org.eclipse.jgit.transport.RemoteRefUpdate.Status status = update.getStatus();
                if (status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK)
                        || status.equals(org.eclipse.jgit.transport.RemoteRefUpdate.Status.UP_TO_DATE)) {
                    LogHelper.log(new Status(IStatus.INFO, Activator.PI_GIT, 1, "Push succeed: " + this, null));
                } else {
                    throw new CoreException(new Status(IStatus.ERROR, Activator.PI_GIT, IStatus.ERROR,
                            status.toString(), null));
                }
            }
        }
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.PI_GIT, IStatus.ERROR, e.getMessage(), e));
    }
}