return db;
}
+ /**
+ * Adds a repository to the list of repositories which is closed at the end
+ * of the tests
+ *
+ * @param r
+ * the repository to be closed
+ */
+ public void addRepoToClose(Repository r) {
+ toClose.add(r);
+ }
+
/**
* Creates a new unique directory for a test repository
*
command.setURI("file://"
+ git.getRepository().getWorkTree().getPath());
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
assertNotNull(git2);
ObjectId id = git2.getRepository().resolve("tag-for-blob");
assertNotNull(id);
command.setURI("file://"
+ git.getRepository().getWorkTree().getPath());
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
+
assertNotNull(git2);
assertEquals(git2.getRepository().getFullBranch(),
"refs/heads/master");
+ git.getRepository().getWorkTree().getPath());
command.setNoCheckout(true);
git2 = command.call();
+ addRepoToClose(git2.getRepository());
+
assertNotNull(git2);
assertEquals(git2.getRepository().getFullBranch(),
"refs/heads/master");
+ git.getRepository().getWorkTree().getPath());
command.setBare(true);
git2 = command.call();
+ addRepoToClose(git2.getRepository());
+
assertNotNull(git2);
assertEquals(git2.getRepository().getFullBranch(),
"refs/heads/master");
command.setURI("file://"
+ git.getRepository().getWorkTree().getPath());
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
assertNotNull(git2);
assertEquals(git2.getRepository().getFullBranch(),
"refs/heads/master");
+ git.getRepository().getWorkTree().getPath());
command.setBare(true);
git2 = command.call();
+ addRepoToClose(git2.getRepository());
assertNotNull(git2);
assertEquals(git2.getRepository().getFullBranch(),
"refs/heads/master");
.setURI(db.getDirectory().toURI().toString())
.setDirectory(createUniqueTestGitDir(true)).call()
.getRepository();
+ addRepoToClose(bareRepo);
}
@Test
InitCommand command = new InitCommand();
command.setDirectory(directory);
Repository repository = command.call().getRepository();
+ addRepoToClose(repository);
assertNotNull(repository);
} catch (Exception e) {
fail(e.getMessage());
command.setDirectory(directory);
command.setBare(true);
Repository repository = command.call().getRepository();
+ addRepoToClose(repository);
assertNotNull(repository);
assertTrue(repository.isBare());
} catch (Exception e) {
+ git.getRepository().getWorkTree().getPath());
command.setCloneAllBranches(true);
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
+
LsRemoteCommand lsRemoteCommand = git2.lsRemote();
Collection<Ref> refs = lsRemoteCommand.call();
+ git.getRepository().getWorkTree().getPath());
command.setCloneAllBranches(true);
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
LsRemoteCommand lsRemoteCommand = git2.lsRemote();
lsRemoteCommand.setTags(true);
+ git.getRepository().getWorkTree().getPath());
command.setCloneAllBranches(true);
Git git2 = command.call();
+ addRepoToClose(git2.getRepository());
LsRemoteCommand lsRemoteCommand = git2.lsRemote();
lsRemoteCommand.setHeads(true);