TestRepository: Expose a Git instance

Change-Id: I2fab7dd9a24205686db4724e77c0fd0a28f2075e
This commit is contained in:
Dave Borowitz 2015-03-17 15:15:45 -07:00
parent fd402f71a3
commit be08dcb6b5
1 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,7 @@
import java.util.List;
import java.util.Set;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.dircache.DirCache;
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEditor;
@ -127,6 +128,8 @@ public class TestRepository<R extends Repository> {
private final R db;
private final Git git;
private final RevWalk pool;
private final ObjectInserter inserter;
@ -155,6 +158,7 @@ public TestRepository(R db) throws IOException {
*/
public TestRepository(R db, RevWalk rw) throws IOException {
this.db = db;
this.git = Git.wrap(db);
this.pool = rw;
this.inserter = db.newObjectInserter();
this.now = 1236977987000L;
@ -170,6 +174,14 @@ public RevWalk getRevWalk() {
return pool;
}
/**
* @return an API wrapper for the underlying repository. This wrapper does
* not allocate any new resources and need not be closed (but closing
* it is harmless). */
public Git git() {
return git;
}
/** @return current time adjusted by {@link #tick(int)}. */
public Date getClock() {
return new Date(now);