/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
final Optional<Remote> remote = command(RemoteResolve.class).setName(name).call(); if (!remote.isPresent()) { throw new RemoteException(StatusCode.REMOTE_NOT_FOUND); configDatabase().removeSection(remoteSection); }}; ImmutableSet<Ref> localRemoteRefs = command(ForEachRef.class) .setFilter(fn).call(); for (Ref localRef : localRemoteRefs) { command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call(); Stream<BranchConfig> branchesMappedToThisRemote = command(BranchConfigOp.class).getAll() .stream().filter(c -> name.equals(c.getRemoteName().orElse(null))); command(BranchConfigOp.class).setName(localBranch.getName()).setRemoteBranch(null) .setRemoteName(null).setDescription(c.getDescription().orElse(null)).set(); String msg = String.format("Removed branch tracking of %s to %s/%s", localBranch, name,
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
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; }
/** * 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()); }
@Test public void testRemoveNonexistentRemote() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class); exception.expect(RemoteException.class); remoteRemove.setName("nonexistent").call(); }
@Test public void testRemoveRemote() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class); Remote deletedRemote = remoteRemove.setName(remoteName).call(); assertEquals(remoteName, deletedRemote.getName()); assertEquals(remoteURL, deletedRemote.getFetchURL()); assertEquals(remoteURL, deletedRemote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), deletedRemote.getFetchSpec()); }
@Test public void testRemoveRemoteWithRefs() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); String refName = Ref.REMOTES_PREFIX + remoteName + "/branch1"; geogig.command(UpdateRef.class).setName(refName).setNewValue(ObjectId.NULL).call(); final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class); Remote deletedRemote = remoteRemove.setName(remoteName).call(); Optional<Ref> remoteRef = geogig.command(RefParse.class).setName(refName).call(); assertFalse(remoteRef.isPresent()); assertEquals(remoteName, deletedRemote.getName()); assertEquals(remoteURL, deletedRemote.getFetchURL()); assertEquals(remoteURL, deletedRemote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), deletedRemote.getFetchSpec()); }
@Test public void testRemoveRemoteWithNoURL() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); final ConfigOp config = geogig.command(ConfigOp.class); config.setAction(ConfigAction.CONFIG_UNSET).setName("remote." + remoteName + ".url").call(); final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class); Remote deletedRemote = remoteRemove.setName(remoteName).call(); assertEquals(remoteName, deletedRemote.getName()); assertEquals("", deletedRemote.getFetchURL()); assertEquals("", deletedRemote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), deletedRemote.getFetchSpec()); }
@Test public void testRemoveRemoteWithNoFetch() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); final ConfigOp config = geogig.command(ConfigOp.class); config.setAction(ConfigAction.CONFIG_UNSET).setName("remote." + remoteName + ".fetch") .call(); final RemoteRemoveOp remoteRemove = geogig.command(RemoteRemoveOp.class); Remote deletedRemote = remoteRemove.setName(remoteName).call(); assertEquals(remoteName, deletedRemote.getName()); assertEquals(remoteURL, deletedRemote.getFetchURL()); assertEquals(remoteURL, deletedRemote.getPushURL()); assertEquals("", deletedRemote.getFetchSpec()); } }