/** * Search for a repository in the local path, or the main repository path. * * @param path the repository name * @param localPath a repository to look first * @return the repository * @throws IOException if an I/O error occurred */ public Repository findRepository(String path, Repository localPath) throws IOException { // To be consistent, always return absolute repository if path is absolute // if we make this dependent on whether files exist we introduce a lot of // vague and undetermined behaviour. File file = new File(path); if (file.isAbsolute()) { return new FileRepository(file); } if (localPath != null) { Repository repository = localPath.getChildRepository(path); if (repository != null && repository.exists()) { return repository; } } return config.getRepository(normalizePath(path)); }