/** * Open a new transport instance to connect two repositories. * * @param local * existing local repository. * @param uri * location of the remote repository. * @return the new transport instance. Never null. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ public static Transport open(Repository local, URIish uri) throws NotSupportedException, TransportException { return open(local, uri, null); }
if (doesNotExist(cfg)) { final ArrayList<Transport> transports = new ArrayList<>(1); transports.add(open(local, new URIish(remote), null)); return transports;
/** * Open a new transport instance to connect two repositories. * <p> * This method assumes * {@link org.eclipse.jgit.transport.Transport.Operation#FETCH}. * * @param local * existing local repository. * @param cfg * configuration describing how to connect to the remote * repository. * @return the new transport instance. Never null. In case of multiple URIs * in remote configuration, only the first is chosen. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. * @throws java.lang.IllegalArgumentException * if provided remote configuration doesn't have any URI * associated. */ public static Transport open(Repository local, RemoteConfig cfg) throws NotSupportedException, TransportException { return open(local, cfg, Operation.FETCH); }
private Set<String> listRemoteBranches(String remote) throws NotSupportedException, TransportException, URISyntaxException { Set<String> branches = new HashSet<>(); try (final Repository repo = getRepository()) { StoredConfig config = repo.getConfig(); try (final Transport tn = Transport.open(repo, new URIish(config.getString("remote",remote,"url")))) { tn.setCredentialsProvider(getProvider()); try (final FetchConnection c = tn.openFetch()) { for (final Ref r : c.getRefs()) { if (r.getName().startsWith(R_HEADS)) branches.add("refs/remotes/"+remote+"/"+r.getName().substring(R_HEADS.length())); } } } } return branches; }
/** * Open a new transport instance to connect two repositories. * <p> * This method assumes * {@link org.eclipse.jgit.transport.Transport.Operation#FETCH}. * * @param local * existing local repository. * @param remote * location of the remote repository - may be URI or remote * configuration name. * @return the new transport instance. Never null. In case of multiple URIs * in remote configuration, only the first is chosen. * @throws java.net.URISyntaxException * the location is not a remote defined in the configuration * file and is not a well-formed URL. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ public static Transport open(Repository local, String remote) throws NotSupportedException, URISyntaxException, TransportException { return open(local, remote, Operation.FETCH); }
@Override protected void run() throws Exception { final Transport tn = Transport.open(db, remote); if (0 <= timeout) tn.setTimeout(timeout); final FetchConnection c = tn.openFetch(); try { for (final Ref r : c.getRefs()) { show(r.getObjectId(), r.getName()); if (r.getPeeledObjectId() != null) show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$ } } finally { c.close(); tn.close(); } }
/** {@inheritDoc} */ @Override protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
/** * Open new transport instances to connect two repositories. * * @param local * existing local repository. * @param cfg * configuration describing how to connect to the remote * repository. * @param op * planned use of the returned Transport; the URI may differ * based on the type of connection desired. * @return the list of new transport instances for every URI in remote * configuration. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ public static List<Transport> openAll(final Repository local, final RemoteConfig cfg, final Operation op) throws NotSupportedException, TransportException { final List<URIish> uris = getURIs(cfg, op); final List<Transport> transports = new ArrayList<>(uris.size()); for (URIish uri : uris) { final Transport tn = open(local, uri, cfg.getName()); tn.applyConfig(cfg); transports.add(tn); } return transports; }
throw new IllegalArgumentException(MessageFormat.format( JGitText.get().remoteConfigHasNoURIAssociated, cfg.getName())); final Transport tn = open(local, uris.get(0), cfg.getName()); tn.applyConfig(cfg); return tn;
private void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }
/** * Open a new transport instance to connect two repositories. * * @param local * existing local repository. * @param uri * location of the remote repository. * @return the new transport instance. Never null. * @throws org.eclipse.jgit.errors.NotSupportedException * the protocol specified is not supported. * @throws org.eclipse.jgit.errors.TransportException * the transport cannot open this URI. */ public static Transport open(Repository local, URIish uri) throws NotSupportedException, TransportException { return open(local, uri, null); }
/** * Open a new transport instance to connect two repositories. * * @param local * existing local repository. * @param uri * location of the remote repository. * @return the new transport instance. Never null. * @throws NotSupportedException * the protocol specified is not supported. * @throws TransportException * the transport cannot open this URI. */ public static Transport open(final Repository local, final URIish uri) throws NotSupportedException, TransportException { return open(local, uri, null); }
checkCallable(); try (Transport transport = Transport.open(repo, remote)) { transport.setCheckFetchedObjects(checkFetchedObjects); transport.setRemoveDeletedRefs(isRemoveDeletedRefs());
protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
/** {@inheritDoc} */ @Override protected void blockingFetch(Repository repo, ReplicaFetchRequest req) throws NotSupportedException, TransportException { try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } fetch(transport, req); } }
private FetchResult runFetch() throws URISyntaxException, IOException { final Transport tn = Transport.open(db, remoteName); final FetchResult r; try { tn.setTagOpt(TagOpt.FETCH_TAGS); r = tn.fetch(new TextProgressMonitor(), null); } finally { tn.close(); } showFetchResult(r); return r; }
private void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }
private void push(Repository repo, ReplicaPushRequest req) throws NotSupportedException, TransportException, IOException { Map<String, Ref> adv; List<RemoteCommand> cmds = asUpdateList(req.getCommands()); try (Transport transport = Transport.open(repo, uri)) { RemoteConfig rc = getRemoteConfig(); if (rc != null) { transport.applyConfig(rc); } transport.setPushAtomic(true); adv = push(repo, transport, cmds); } for (RemoteCommand c : cmds) { c.copyStatusToResult(); } req.setRefs(adv); }