/** * @param remoteName the name or URL of a remote repository to fetch from * @return {@code this} */ public FetchOp addRemote(final String remoteName) { checkNotNull(remoteName); return addRemote(command(RemoteResolve.class).setName(remoteName)); }
@Override public Optional<Remote> get() { return call(); } }
ConfigDatabase config = configDatabase(); List<String> allRemotes = config.getAllSubsections("remote"); if (allRemotes.contains(name)) {
/** * @param remoteName the name or URL of a remote repository to fetch from * @return {@code this} */ public PullOp setRemote(final String remoteName) { checkNotNull(remoteName); return setRemote(command(RemoteResolve.class).setName(remoteName)); }
/** * @param remoteName the name or URL of a remote repository to fetch from * @return {@code this} */ public FetchOp addRemote(final String remoteName) { checkNotNull(remoteName); return addRemote(command(RemoteResolve.class).setName(remoteName)); }
private Remote addRemote(Repository clone) { final boolean sparse = clone.isSparse(); if (sparse || singleBranch) { checkArgument(this.branch.isPresent(), "No branch specified for sparse clone."); } {// won't be necessary once ClopeOp actually creates the clone repo Optional<Remote> remote = clone.command(RemoteResolve.class).setName(remoteName).call(); if (remote.isPresent()) { clone.command(RemoteRemoveOp.class).setName(remoteName).call(); } } final @Nullable String branch = this.branch.orNull(); RemoteAddOp cmd = clone.command(RemoteAddOp.class)// .setName(remoteName)// .setURL(remoteURI.toString())// .setMapped(sparse)// .setUserName(username)// .setPassword(password); if (sparse || singleBranch) { cmd.setBranch(branch); } Remote remote = cmd.call(); return remote; }
private void createFilterFile(Map<String, String> filters) { String filterBlob = ""; for (Entry<String, String> entry : filters.entrySet()) { String featurePath = entry.getKey(); String filter = entry.getValue(); filterBlob += "[" + featurePath + "]\n"; filterBlob += "type = CQL\n"; filterBlob += "filter = " + filter + "\n"; } try { localGeogig.repo.blobStore().putBlob(Blobs.SPARSE_FILTER_BLOB_KEY, filterBlob.getBytes()); Optional<Remote> remoteInfo = localGeogig.geogig.command(RemoteResolve.class) .setName(REMOTE_NAME).call(); Preconditions.checkState(remoteInfo.isPresent()); LocalMappedRemoteRepo remoteRepo; remoteRepo = spy( new LocalMappedRemoteRepo(remoteInfo.get(), remoteGeogig.envHome.toURI())); doNothing().when(remoteRepo).close(); remoteRepo.setRepository(remoteGeogig.geogig.getRepository()); localGeogig.remoteOverride.put(REMOTE_NAME, remoteRepo); } catch (Exception e) { e.printStackTrace(); throw e; } }
/** * Pull from a remote that's not being saved as named remote in the repository */ public @Test void testPullMergeNonPersistedRemote() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); Remote removedOrigin = localGeogig.geogig.command(RemoteRemoveOp.class).setName("origin") .call(); assertFalse(localGeogig.geogig.command(RemoteResolve.class).setName("origin").call() .isPresent()); // Pull the commit PullOp pull = pullOp(); pull.setRemote(removedOrigin).call(); List<RevCommit> logged = log(localGeogig.repo); assertEquals(expectedMaster, logged); }
@Test public void testPullMultipleRefspecsNonPersistedRemote() throws Exception { // Add a commit to the remote insertAndAdd(remoteGeogig.geogig, lines3); RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call(); expectedMaster.addFirst(commit); // remove the remote Remote removedOrigin = localGeogig.geogig.command(RemoteRemoveOp.class).setName("origin") .call(); assertFalse(localGeogig.geogig.command(RemoteResolve.class).setName("origin").call() .isPresent()); // Pull the commit PullOp pull = pullOp(); pull.setRemote(removedOrigin);// client supplied remote pull.addRefSpec("master:newbranch"); pull.addRefSpec("Branch1:newbranch2"); pull.call(); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch").isPresent()); assertTrue(getRef(localGeogig.repo, "refs/remotes/origin/newbranch2").isPresent()); assertEquals(7, log(localGeogig.repo).size()); }