private void handleRepoRename(RepositoryInfo oldRepo, RepositoryInfo newRepo) { if (Objects.equal(oldRepo.getId(), newRepo.getId())) { // repos have the same ID, check the names final String oldName = oldRepo.getRepoName(); final String newName = newRepo.getRepoName(); if (!Objects.equal(oldName, newName)) { // name has been changed, update the repo try { getRepository(oldRepo.getId()) .command(ConfigOp.class) .setAction(ConfigOp.ConfigAction.CONFIG_SET) .setName("repo.name") .setScope(ConfigOp.ConfigScope.LOCAL) .setValue(newName) .call(); } catch (IOException ioe) { // log? } } } }
private void create(final RepositoryInfo repoInfo) { // File targetDirectory = new File(repoInfo.getLocation()); // Preconditions.checkArgument(!isGeogigDirectory(targetDirectory)); URI repoURI = repoInfo.getLocation(); RepositoryResolver resolver = RepositoryResolver.lookup(repoURI); if (!resolver.repoExists(repoURI)) { Hints hints = new Hints(); hints.set(Hints.REPOSITORY_URL, repoURI); hints.set(Hints.REPOSITORY_NAME, repoInfo.getRepoName()); Context context = GlobalContextBuilder.builder().build(hints); GeoGIG geogig = new GeoGIG(context); try { Repository repository = geogig.command(InitOp.class).call(); Preconditions.checkState(repository != null); } finally { geogig.close(); } } }