@Override public Optional<Remote> get() { return call(); } }
/** * @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)); }
@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 testAddRemoteWithBranch() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; String branch = "mybranch"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).setBranch(branch).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals("+refs/heads/" + branch + ":refs/remotes/" + remoteName + "/" + branch, remote.getFetchSpec()); }
@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 testAddRemoteNullBranch() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).setBranch(null).call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); }
/** * @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)); }
@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 testAddRemoteEmptyBranch() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName = "myremote"; String remoteURL = "http://test.com"; Remote remote = remoteAdd.setName(remoteName).setURL(remoteURL).setBranch("").call(); assertEquals(remoteName, remote.getName()); assertEquals(remoteURL, remote.getFetchURL()); assertEquals(remoteURL, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName), remote.getFetchSpec()); }
/** * @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)); }
@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()); } }
@Test public void testAddRemoteThatExists() { 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()); exception.expect(RemoteException.class); remoteAdd.setName(remoteName).setURL("someotherurl.com").call(); }
@Test public void testAddMultipleRemotes() { final RemoteAddOp remoteAdd = geogig.command(RemoteAddOp.class); String remoteName1 = "myremote"; String remoteURL1 = "http://test.com"; String remoteName2 = "myremote2"; String remoteURL2 = "http://test2.org"; Remote remote = remoteAdd.setName(remoteName1).setURL(remoteURL1).call(); assertEquals(remoteName1, remote.getName()); assertEquals(remoteURL1, remote.getFetchURL()); assertEquals(remoteURL1, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName1), remote.getFetchSpec()); remote = remoteAdd.setName(remoteName2).setURL(remoteURL2).call(); assertEquals(remoteName2, remote.getName()); assertEquals(remoteURL2, remote.getFetchURL()); assertEquals(remoteURL2, remote.getPushURL()); }