FileRepositoryOperation implements FileCallable<Repository> { public Repository invoke(File file, VirtualChannel channel) throws IOException { String directory = repo.getDirectory(); File gitDir; if (directory == null || directory.length() == 0 || ".".equals(directory)) gitDir = file; else gitDir = new File(file, directory); FileRepositoryBuilder builder = new FileRepositoryBuilder(); builder.setFS(FS.DETECTED); if (Constants.DOT_GIT.equals(gitDir.getName())) builder.setGitDir(gitDir); else builder.setWorkTree(gitDir); builder.setMustExist(true); try { return builder.build(); } catch (RepositoryNotFoundException rnfe) { return null; } } FileRepositoryOperation(BuildRepository repository); Repository invoke(File file, VirtualChannel channel);  }
@Test public void resolveExisting() throws Exception { BuildRepository buildRepo = new BuildRepository("a", "b", null); FileRepositoryOperation op = new FileRepositoryOperation(buildRepo); Repository repo = op.invoke(git.repo().getDirectory(), null); assertNotNull(repo); assertEquals(git.repo().getDirectory(), repo.getDirectory()); }