InitOperation 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); if (Constants.DOT_GIT.equals(gitDir.getName())) gitDir = new File(gitDir, Constants.DOT_GIT); InitCommand init = Git.init(); init.setBare(false); init.setDirectory(gitDir); return init.call().getRepository(); } InitOperation(final BuildRepository repository); Repository invoke(File file, VirtualChannel channel);  }
@Test public void initAndResolveRepository() throws Exception { BuildRepository repo = new BuildRepository(git.repo().getDirectory() .toURI().toString(), BuildRepository.BRANCH_DEFAULT, null); InitOperation op = new InitOperation(repo); File dir = git.tempDirectory(); Repository gitRepo = op.invoke(dir, null); assertNotNull(repo); FileRepositoryOperation resolveOp = new FileRepositoryOperation(repo); Repository resolved = resolveOp.invoke(dir, null); assertNotNull(resolved); assertEquals(gitRepo.getDirectory(), resolved.getDirectory()); }