private void remoteList(CommandContext context, final Context geogig) { final List<Remote> remotes = geogig.command(RemoteListOp.class).call(); context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeRemoteListResponse(remotes, verbose); out.finish(); } }); }
/** * Executes the remote-list operation. * * @return {@code List<Remote>} of all remotes found in the config database, may be empty. */ @Override protected ImmutableList<Remote> _call() { ConfigDatabase config = configDatabase(); List<String> remotes = config.getAllSubsections("remote"); List<Remote> allRemotes = new ArrayList<Remote>(); for (String remoteName : remotes) { String remoteSection = "remote." + remoteName; Optional<String> remoteFetchURL = config.get(remoteSection + ".url"); Optional<String> remoteFetch = config.get(remoteSection + ".fetch"); Optional<String> remoteMapped = config.get(remoteSection + ".mapped"); Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch"); Optional<String> remoteUserName = config.get(remoteSection + ".username"); Optional<String> remotePassword = config.get(remoteSection + ".password"); if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) { Optional<String> remotePushURL = config.get(remoteSection + ".pushurl"); allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull())); } } return ImmutableList.copyOf(allRemotes); } }
private List<RemoteInfo> loadRemoteInfos(RepositoryInfo repo) { String repoId = repo.getId(); if (null == repoId) { return new ArrayList<>(); } ArrayList<RemoteInfo> list = new ArrayList<>(); Repository geogig; try { geogig = RepositoryManager.get().getRepository(repoId); if (geogig != null) { ImmutableList<Remote> geogigRemotes = geogig.command(RemoteListOp.class).call(); list = RemoteInfo.fromList(geogigRemotes); } } catch (Exception e) { LOGGER.warn("Failed to load Remotes for repository", e); } return list; }
/** * Executes the remote-list operation. * * @return {@code List<Remote>} of all remotes found in the config database, may be empty. */ @Override protected ImmutableList<Remote> _call() { ConfigDatabase config = configDatabase(); List<String> remotes = config.getAllSubsections("remote"); List<Remote> allRemotes = new ArrayList<Remote>(); for (String remoteName : remotes) { String remoteSection = "remote." + remoteName; Optional<String> remoteFetchURL = config.get(remoteSection + ".url"); Optional<String> remoteFetch = config.get(remoteSection + ".fetch"); Optional<String> remoteMapped = config.get(remoteSection + ".mapped"); Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch"); Optional<String> remoteUserName = config.get(remoteSection + ".username"); Optional<String> remotePassword = config.get(remoteSection + ".password"); if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) { Optional<String> remotePushURL = config.get(remoteSection + ".pushurl"); allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull())); } } return ImmutableList.copyOf(allRemotes); } }
remotes.clear(); ImmutableList<Remote> localRemotes = repo.command(RemoteListOp.class).call(); remotes.addAll(localRemotes); } else if (remotes.isEmpty()) {
remotes.clear(); ImmutableList<Remote> localRemotes = repo.command(RemoteListOp.class).call(); remotes.addAll(localRemotes); } else if (remotes.isEmpty()) {
remotes.clear(); ImmutableList<Remote> localRemotes = repo.command(RemoteListOp.class).call(); remotes.addAll(localRemotes); } else if (remotes.isEmpty()) {
remotes.clear(); ImmutableList<Remote> localRemotes = repo.command(RemoteListOp.class).call(); remotes.addAll(localRemotes); } else if (remotes.isEmpty()) {
@Test public void testListNoRemotes() { final RemoteListOp remoteList = geogig.command(RemoteListOp.class); ImmutableList<Remote> allRemotes = remoteList.call(); assertTrue(allRemotes.isEmpty()); }
@Test public void testListNoRemotes() { final RemoteListOp remoteList = geogig.command(RemoteListOp.class); ImmutableList<Remote> allRemotes = remoteList.call(); assertTrue(allRemotes.isEmpty()); }
/** * Executes the remote list command. */ @Override public void runInternal(GeogigCLI cli) throws IOException { final ImmutableList<Remote> remoteList; try { remoteList = cli.getGeogig().command(RemoteListOp.class).call(); } catch (ConfigException e) { throw new CommandFailedException("Could not access the config database.", e); } for (Remote remote : remoteList) { if (verbose) { cli.getConsole() .println(remote.getName() + " " + remote.getFetchURL() + " (fetch)"); cli.getConsole().println(remote.getName() + " " + remote.getPushURL() + " (push)"); } else { cli.getConsole().println(remote.getName()); } } }
/** * Executes the remote list command. */ @Override public void runInternal(GeogigCLI cli) throws IOException { final ImmutableList<Remote> remoteList; try { remoteList = cli.getGeogig().command(RemoteListOp.class).call(); } catch (ConfigException e) { throw new CommandFailedException("Could not access the config database.", e); } for (Remote remote : remoteList) { if (verbose) { cli.getConsole() .println(remote.getName() + " " + remote.getFetchURL() + " (fetch)"); cli.getConsole().println(remote.getName() + " " + remote.getPushURL() + " (push)"); } else { cli.getConsole().println(remote.getName()); } } }
/** * Executes the remote list command. */ @Override public void runInternal(GeogigCLI cli) throws IOException { final ImmutableList<Remote> remoteList; try { remoteList = cli.getGeogig().command(RemoteListOp.class).call(); } catch (ConfigException e) { throw new CommandFailedException("Could not access the config database.", e); } for (Remote remote : remoteList) { if (verbose) { cli.getConsole() .println(remote.getName() + " " + remote.getFetchURL() + " (fetch)"); cli.getConsole().println(remote.getName() + " " + remote.getPushURL() + " (push)"); } else { cli.getConsole().println(remote.getName()); } } }
@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("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch()); 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 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 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 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("+refs/heads/*:refs/remotes/" + remoteName + "/*", remote.getFetch()); 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()); } }
ImmutableList<Remote> allRemotes = remoteList.call();
ImmutableList<Remote> allRemotes = remoteList.call();