Example usage for org.eclipse.jgit.transport Transport openAll

List of usage examples for org.eclipse.jgit.transport Transport openAll

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport Transport openAll.

Prototype

public static List<Transport> openAll(final Repository local, final RemoteConfig cfg, final Operation op)
        throws NotSupportedException, TransportException 

Source Link

Document

Open new transport instances to connect two repositories.

Usage

From source file:org.kuali.student.git.importer.JGitPushMain.java

License:Educational Community License

public static void push(Repository repo, String remoteName, List<RemoteRefUpdate> refsToUpdate,
        String remoteUserName, String remotePassword) throws IOException, URISyntaxException {

    ArrayList<PushResult> pushResults = new ArrayList<PushResult>(3);

    RemoteConfig config = new RemoteConfig(repo.getConfig(), remoteName);

    final List<Transport> transports;
    transports = Transport.openAll(repo, config, Transport.Operation.PUSH);

    for (final Transport transport : transports) {
        transport.setPushThin(false);//from   w ww  .ja v  a 2s  .  c o  m
        transport.setOptionReceivePack(RemoteConfig.DEFAULT_RECEIVE_PACK);
        transport.setDryRun(false);

        configure(transport, remoteUserName, remotePassword);

        try {
            PushResult result = transport.push(new TextProgressMonitor(), refsToUpdate, System.out);
            pushResults.add(result);

        } catch (TransportException e) {
            throw new TransportException(e.getMessage(), e);
        } finally {
            transport.close();
        }
    }

}