/** * @param repositoryLocation the URI with the location of the repository to load * @return a {@link Repository} loaded from the given URI, already {@link Repository#open() * open} * @throws IllegalArgumentException if no registered {@link RepositoryResolver} implementation * can load the repository at the given location * @throws RepositoryConnectionException if the repository can't be opened */ public static Repository load(URI repositoryLocation) throws RepositoryConnectionException { RepositoryResolver initializer = RepositoryResolver.lookup(repositoryLocation); Repository repository = initializer.open(repositoryLocation); return repository; }
/** * @param repositoryLocation the URI with the location of the repository to load * @return a {@link Repository} loaded from the given URI, already {@link Repository#open() * open} * @throws IllegalArgumentException if no registered {@link RepositoryResolver} implementation * can load the repository at the given location * @throws RepositoryConnectionException if the repository can't be opened */ public static Repository load(URI repositoryLocation) throws RepositoryConnectionException { RepositoryResolver initializer = RepositoryResolver.lookup(repositoryLocation); Repository repository = initializer.open(repositoryLocation); return repository; }
repo = initializer.open(repositoryUri); } catch (RepositoryConnectionException | RuntimeException e) { throw new IOException(e.getMessage(), e);
private RepoInfo toRepoInfo(RepositoryResolver resolver, URI rootRepoURI, String repoName) { URI repoURI = resolver.buildRepoURI(rootRepoURI, repoName); Repository repo; try { repo = resolver.open(repoURI); } catch (RepositoryConnectionException e) { throw new CommandFailedException(e); } try { return toRepoInfo(repoName, repo); } finally { repo.close(); } }
resolver.open(location);