private Map<String, String> loadConfig(RepositoryInfo repo, boolean global) { String repoId = repo.getId(); if (null == repoId) { return Maps.newHashMap(); } Repository geogig; try { geogig = RepositoryManager.get().getRepository(repoId); if (geogig != null) { Optional<Map<String, String>> config = geogig.command(ConfigOp.class) // .setAction(ConfigAction.CONFIG_LIST) // .setScope(global ? ConfigScope.GLOBAL : ConfigScope.LOCAL) // .call(); if (config.isPresent()) { return config.get(); } } } catch (Exception e) { LOGGER.warn("Failed to load config for repository", e); } return Maps.newHashMap(); }
@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 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()); } }
@Then("^the Author config of repository \"([^\"]*)\" is set$") public void checkAuthorConfig(final String repo) throws Exception { Repository geogig = context.getRepo(repo); final Optional<URI> repoLocation = geogig.command(ResolveGeogigURI.class).call(); assertTrue("Expected Repository location to be present", repoLocation.isPresent()); // get the config Optional<Map<String, String>> optConfig = geogig.command(ConfigOp.class) .setAction(CONFIG_LIST).setScope(LOCAL).call(); // asseert the user.name and user.email config assertTrue("GeoGig repo config missing", optConfig.isPresent()); Map<String, String> config = optConfig.get(); assertTrue("\"user.name\" missing in repository config", config.containsKey("user.name")); assertEquals("GeoGig User", config.get("user.name")); assertTrue("\"user.email\" missing in repository config", config.containsKey("user.email")); assertEquals("geogig@geogig.org", config.get("user.email")); // add the repo to the set so it can be closed openedRepos.add(repo); }
@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()); } }
/** * Executes the config command with the specified options. * * @return Optional<String> if querying for a value, empty Optional if no matching name was * found. * @throws ConfigException if an error is encountered. More specific information can be found in * the exception's statusCode. */ @Override protected Optional<String> _call() { ConfigScope scope = global ? ConfigScope.GLOBAL : ConfigScope.LOCAL; Optional<Map<String, String>> result = command(ConfigOp.class) .setAction(ConfigAction.CONFIG_GET).setName(name).setScope(scope).call(); if (result.isPresent()) { return Optional.of(result.get().get(name)); } else { return Optional.absent(); } }
@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()); }
/** * Executes the config command with the specified options. * * @return Optional<String> if querying for a value, empty Optional if no matching name was * found. * @throws ConfigException if an error is encountered. More specific information can be found in * the exception's statusCode. */ @Override protected Optional<String> _call() { ConfigScope scope = global ? ConfigScope.GLOBAL : ConfigScope.LOCAL; Optional<Map<String, String>> configGetResult = command(ConfigOp.class) .setAction(ConfigAction.CONFIG_GET).setName(name).setScope(scope).call(); if (configGetResult.isPresent()) { return Optional.of(configGetResult.get().get(name)); } else { return Optional.absent(); } }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }
@Override protected void setUpInternal() throws Exception { // These values should be used during a commit to set author/committer // TODO: author/committer roles need to be defined better, but for // now they are the same thing. repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.name") .setValue("groldan").call(); repo.command(ConfigOp.class).setAction(ConfigAction.CONFIG_SET).setName("user.email") .setValue("groldan@boundlessgeo.com").call(); }