private static Ref pingRemote(Remote remote) throws Exception { Optional<IRemoteRepo> remoteRepo; try { Hints hints = Hints.readOnly(); Repository localRepo = GlobalContextBuilder.builder().build(hints).repository(); remoteRepo = RemoteResolver.newRemote(remote, null); if (!remoteRepo.isPresent()) { throw new IllegalArgumentException("Repository not found or not reachable"); } else { IRemoteRepo repo = remoteRepo.get(); try { repo.open(); Optional<Ref> head = repo.headRef(); return head.orNull(); } finally { repo.close(); } } } catch (Exception e) { throw new IllegalArgumentException("Unable to connect: " + e.getMessage(), e); } }
public LsRemoteOp setRemote(IRemoteRepo remoteRepo) { this.remoteRepo = remoteRepo; this.remote = () -> Optional.of(remoteRepo.getInfo()); return this; }
private boolean anyRemoteIsShallow(FetchArgs args) { for (Remote remote : args.remotes) { try (IRemoteRepo repo = openRemote(remote)) { Integer depth = repo.getDepth().or(0); if (depth.intValue() > 0) { return true; } } } return false; }
public void addRemoteOverride(Remote remote, Repository override) { IRemoteRepo remoteRepo = spy(LocalRemoteResolver.resolve(remote, override)); try { remoteRepo.open(); } catch (RepositoryConnectionException e) { throw new RuntimeException(e); } doNothing().when(remoteRepo).close(); this.remoteOverride.put(remote.getName(), remoteRepo); }
remoteRepo.fetchNewData(repository, newRef, newFetchLimit, getProgressListener()); Optional<Ref> remoteHead = remoteRepo.headRef(); if (remoteHead.isPresent() && !remoteHead.get().getObjectId().isNull()) { updateLocalRef(remoteHead.get(), remote, localRemoteRefs);
@Override protected IRemoteRepo _call() { Preconditions.checkNotNull(remote, "remote to connect to not provided"); Optional<IRemoteRepo> opRemote = RemoteResolver.newRemote(remote, remoteHints); checkArgument(opRemote.isPresent(), "Unknown remote type: " + remote.getFetchURL()); IRemoteRepo remoteRepo = opRemote.get(); try { remoteRepo.open(); } catch (RepositoryConnectionException e) { throw new IllegalStateException("Failed to connect to remote: " + e.getMessage(), e); } return remoteRepo; }
private void remotePing(CommandContext context, final Context geogig) { Optional<Remote> remote; try { remote = geogig.command(RemoteResolve.class).setName(remoteName).call(); } catch (RemoteException re) { throw new CommandSpecException(re.statusCode.toString(), HttpStatus.BAD_REQUEST); } boolean remotePingResponse = false; if (remote.isPresent()) { try (IRemoteRepo rr = geogig.command(OpenRemote.class).setRemote(remote.get()) .readOnly().call()) { rr.headRef(); remotePingResponse = true; } catch (Exception e) { // Do nothing, we will write the response later. } } final boolean pingSuccess = remotePingResponse; context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeRemotePingResponse(pingSuccess); out.finish(); } }); }
Preconditions.checkState(remote.equals(remoteRepo.getInfo())); progress.setDescription("Fetching " + remoteRepo.getInfo()); final List<LocalRemoteRef> localToRemoteRemoteRefs = resolveRemoteRefs(remoteRepo); return null; remoteRepo.command(SendPackOp.class)// args.prune); transferSummary.addAll(remote.getFetchURL(), Lists.newArrayList(remoteRemoteRefs)); progress.setDescription("Fetched " + remoteRepo.getInfo());
private TransferSummary callInternal(IRemoteRepo remoteRepo) { final Remote remote = this.remote; @Nullable String localRefSpec; @Nullable String remoteRefSpec; boolean force; TransferSummary result = new TransferSummary(); for (TransferableRef ref : this.refsToPush) { localRefSpec = ref.getLocalRef(); remoteRefSpec = ref.getRemoteRef(); force = ref.isForceUpdate(); if (ref.isDelete()) { Optional<Ref> deleted = remoteRepo.deleteRef(remoteRefSpec); if (deleted.isPresent()) { RefDiff deleteResult = RefDiff.added(deleted.get()); result.add(remote.getPushURL(), deleteResult); } } else { Optional<Ref> localRef = refParse(localRefSpec); checkState(localRef.isPresent(), "RefSpec %s does not exist", localRefSpec); Optional<Ref> newRef = push(remoteRepo, remote, localRef.get(), remoteRefSpec); if (newRef.isPresent()) { RefDiff deleteResult = new RefDiff(localRef.get(), newRef.get()); result.add(remote.getPushURL(), deleteResult); } } } return result; }
localRemoteResults = remoteRepo.command(SendPackOp.class)//
public void addRemoteOverride(Remote remote, Repository override) { IRemoteRepo remoteRepo = spy(LocalRemoteResolver.resolve(remote, override)); try { remoteRepo.open(); } catch (RepositoryConnectionException e) { throw Throwables.propagate(e); } doNothing().when(remoteRepo).close(); this.remoteOverride.put(remote.getName(), remoteRepo); }
remoteRepo.fetchNewData(repository, newRef, newFetchLimit, getProgressListener()); Optional<Ref> remoteHead = remoteRepo.headRef(); if (remoteHead.isPresent() && !remoteHead.get().getObjectId().isNull()) { updateLocalRef(remoteHead.get(), remote, localRemoteRefs);
@Override protected IRemoteRepo _call() { Preconditions.checkNotNull(remote, "remote to connect to not provided"); Optional<IRemoteRepo> opRemote = RemoteResolver.newRemote(remote, remoteHints); checkArgument(opRemote.isPresent(), "Unknown remote type: " + remote.getFetchURL()); IRemoteRepo remoteRepo = opRemote.get(); try { remoteRepo.open(); } catch (RepositoryConnectionException e) { throw new IllegalStateException("Failed to connect to remote: " + e.getMessage(), e); } return remoteRepo; }