private Ref toLocal(Ref remoteRef) { Optional<String> localName = remote.mapToRemote(remoteRef.getName()); Preconditions.checkArgument(localName.isPresent(), "Can't map %s to local ref using %s", remoteRef.getName(), remote.getFetchSpec()); Ref localRef; if (remoteRef instanceof SymRef) { Ref target = toLocal(remoteRef.peel()); localRef = new SymRef(localName.get(), target); } else { localRef = new Ref(localName.get(), remoteRef.getObjectId()); } return localRef; }
private Ref toRemote(Ref localRef) { Optional<String> remoteName = remote.mapToLocal(localRef.getName()); Preconditions.checkArgument(remoteName.isPresent(), "Can't map %s to remote ref using %s", localRef.getName(), remote.getFetchSpec()); Ref remoteRef; if (localRef instanceof SymRef) { Ref target = toRemote(localRef.peel()); remoteRef = new SymRef(remoteName.get(), target); } else { remoteRef = new Ref(remoteName.get(), localRef.getObjectId()); } return remoteRef; }
private PullResult pull(final GeogigTransaction context, final Remote remote) throws MergeConflictsException { String fetchSpec = remote.getFetchSpec(); PullResult pullResult = context.command(PullOp.class)// .setAll(false)// .setIncludeIndexes(true)// .setRemote(remote)// .addRefSpec(fetchSpec)// .setNoFastForward(true)// .setMessage(message)// .setProgressListener(getProgressListener())// .call(); return pullResult; }
assertEquals(remoteURL1, remote.getFetchURL()); assertEquals(remoteURL1, remote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName1), remote.getFetchSpec()); assertEquals(remoteURL2, remote.getPushURL()); assertEquals("+refs/heads/" + branch + ":refs/remotes/" + remoteName2 + "/" + branch, remote.getFetchSpec()); assertEquals(remoteURL1, firstRemote.getFetchURL()); assertEquals(remoteURL1, firstRemote.getPushURL()); assertEquals(Remote.defaultRemoteRefSpec(remoteName1), firstRemote.getFetchSpec()); assertEquals(remoteURL2, secondRemote.getPushURL()); assertEquals("+refs/heads/" + branch + ":refs/remotes/" + remoteName2 + "/" + branch, secondRemote.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()); }
@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 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()); }
String fetchSpec = remote.getFetchSpec(); fetchSpec += ";+refs/tags/*:refs/tags/*"; remote = remote.fetch(fetchSpec);
@Test public void testListRemoteWithNoFetch() { 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 RemoteListOp remoteList = geogig.command(RemoteListOp.class); ImmutableList<Remote> allRemotes = remoteList.call(); assertTrue(allRemotes.isEmpty()); } }
@Test public void testListRemoteWithNoURL() { 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 RemoteListOp remoteList = geogig.command(RemoteListOp.class); ImmutableList<Remote> allRemotes = remoteList.call(); assertTrue(allRemotes.isEmpty()); }
@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 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 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 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 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(); }
assertEquals("fetchurl", remote.getFetchURL()); assertEquals("pushurl", remote.getPushURL()); assertEquals("fetch", remote.getFetchSpec()); assertEquals(true, remote.getMapped()); assertEquals("mappedBranch", remote.getMappedBranch()); assertEquals("fetchurl", remote2.getFetchURL()); assertEquals("pushurl", remote2.getPushURL()); assertEquals("fetch", remote2.getFetchSpec()); assertEquals(false, remote2.getMapped()); assertEquals("*", remote2.getMappedBranch());
@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()); }