R - type of Repository the test data is stored on.public class TestRepository<R extends Repository> extends Object
| Modifier and Type | Class and Description | 
|---|---|
class  | 
TestRepository.BranchBuilder
Helper to build a branch with one or more commits 
 | 
class  | 
TestRepository.CommitBuilder
Helper to generate a commit. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static String | 
AUTHOR  | 
static String | 
AUTHOR_EMAIL  | 
static String | 
COMMITTER  | 
static String | 
COMMITTER_EMAIL  | 
| Constructor and Description | 
|---|
TestRepository(R db)
Wrap a repository with test building tools. 
 | 
TestRepository(R db,
              RevWalk rw)
Wrap a repository with test building tools. 
 | 
TestRepository(R db,
              RevWalk rw,
              MockSystemReader reader)
Wrap a repository with test building tools. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
TestRepository.CommitBuilder | 
amend(AnyObjectId id)
Amend an existing commit. 
 | 
TestRepository.CommitBuilder | 
amendRef(String ref)
Amend an existing ref. 
 | 
RevBlob | 
blob(byte[] content)
Create a new blob object in the repository. 
 | 
RevBlob | 
blob(String content)
Create a new blob object in the repository. 
 | 
TestRepository.BranchBuilder | 
branch(String ref)
Create a new branch builder for this repository. 
 | 
RevCommit | 
cherryPick(AnyObjectId id)
Cherry-pick a commit onto HEAD. 
 | 
TestRepository.CommitBuilder | 
commit()  | 
RevCommit | 
commit(int secDelta,
      RevCommit... parents)
Create a new commit. 
 | 
RevCommit | 
commit(int secDelta,
      RevTree tree,
      RevCommit... parents)
Create a new commit. 
 | 
RevCommit | 
commit(RevCommit... parents)
Create a new commit. 
 | 
RevCommit | 
commit(RevTree tree,
      RevCommit... parents)
Create a new commit. 
 | 
void | 
delete(String ref)
Delete a reference. 
 | 
DirCacheEntry | 
file(String path,
    RevBlob blob)
Construct a regular file mode tree entry. 
 | 
void | 
fsck(RevObject... tips)
Run consistency checks against the object database. 
 | 
RevObject | 
get(RevTree tree,
   String path)
Lookup an entry stored in a tree, failing if not present. 
 | 
Date | 
getDate()  | 
R | 
getRepository()  | 
RevWalk | 
getRevWalk()  | 
TimeZone | 
getTimeZone()  | 
Git | 
git()  | 
ObjectId | 
lightweightTag(String name,
              ObjectId obj)
Tag an object using a lightweight tag. 
 | 
void | 
packAndPrune()
Pack all reachable objects in the repository into a single pack file. 
 | 
<T extends RevObject> | 
parseBody(T object)
Ensure the body of the given object has been parsed. 
 | 
void | 
reset(AnyObjectId id)
Soft-reset HEAD to a detached state. 
 | 
void | 
reset(String name)
Soft-reset HEAD to a different commit. 
 | 
void | 
setAuthorAndCommitter(CommitBuilder c)
Set the author and committer using  
getDate(). | 
RevTag | 
tag(String name,
   RevObject dst)
Construct an annotated tag object pointing at another object. 
 | 
void | 
tick(int secDelta)
Adjust the current time that will used by the next commit. 
 | 
RevTree | 
tree(DirCacheEntry... entries)
Construct a tree from a specific listing of file entries. 
 | 
<T extends AnyObjectId> | 
update(String ref,
      T obj)
Update a reference to point to an object. 
 | 
RevCommit | 
update(String ref,
      TestRepository.CommitBuilder to)
Update a reference to point to an object. 
 | 
void | 
updateServerInfo()
Update the dumb client server info files. 
 | 
public static final String AUTHOR
public static final String AUTHOR_EMAIL
public static final String COMMITTER
public static final String COMMITTER_EMAIL
public TestRepository(R db) throws IOException
db - the test repository to write into.IOExceptionpublic TestRepository(R db, RevWalk rw) throws IOException
db - the test repository to write into.rw - the RevObject pool to use for object lookup.IOExceptionpublic TestRepository(R db, RevWalk rw, MockSystemReader reader) throws IOException
db - the test repository to write into.rw - the RevObject pool to use for object lookup.reader - the MockSystemReader to use for clock and other system
            operations.IOExceptionpublic R getRepository()
public RevWalk getRevWalk()
public Git git()
public Date getDate()
public TimeZone getTimeZone()
public void tick(int secDelta)
secDelta - number of seconds to add to the current time.public void setAuthorAndCommitter(CommitBuilder c)
getDate().c - the commit builder to store.public RevBlob blob(String content) throws Exception
content - file content, will be UTF-8 encoded.Exceptionpublic RevBlob blob(byte[] content) throws Exception
content - binary file content.Exceptionpublic DirCacheEntry file(String path, RevBlob blob) throws Exception
path - path of the file.blob - a blob, previously constructed in the repository.Exceptionpublic RevTree tree(DirCacheEntry... entries) throws Exception
entries - the files to include in the tree. The collection does not need
            to be sorted properly and may be empty.Exceptionpublic RevObject get(RevTree tree, String path) throws Exception
tree - the tree to search.path - the path to find the entry of.Exceptionpublic RevCommit commit(RevCommit... parents) throws Exception
 See commit(int, RevTree, RevCommit...). The tree is the empty
 tree (no files or subdirectories).
parents - zero or more parents of the commit.Exceptionpublic RevCommit commit(RevTree tree, RevCommit... parents) throws Exception
tree - the root tree for the commit.parents - zero or more parents of the commit.Exceptionpublic RevCommit commit(int secDelta, RevCommit... parents) throws Exception
 See commit(int, RevTree, RevCommit...). The tree is the empty
 tree (no files or subdirectories).
public RevCommit commit(int secDelta, RevTree tree, RevCommit... parents) throws Exception
 The author and committer identities are stored using the current
 timestamp, after being incremented by secDelta. The message body
 is empty.
public TestRepository.CommitBuilder commit()
public RevTag tag(String name, RevObject dst) throws Exception
 The tagger is the committer identity, at the current time as specified by
 tick(int). The time is not increased.
 
The tag message is empty.
name - name of the tag. Traditionally a tag name should not start
            with refs/tags/.dst - object the tag should be pointed at.Exceptionpublic RevCommit update(String ref, TestRepository.CommitBuilder to) throws Exception
ref - the name of the reference to update to. If ref does
            not start with refs/ and is not the magic names
            HEAD FETCH_HEAD or MERGE_HEAD, then
            refs/heads/ will be prefixed in front of the given
            name, thereby assuming it is a branch.to - the target object.Exceptionpublic TestRepository.CommitBuilder amendRef(String ref) throws Exception
ref - the name of the reference to amend, which must already exist.
            If ref does not start with refs/ and is not the
            magic names HEAD FETCH_HEAD or MERGE_HEAD, then refs/heads/ will be prefixed in front
            of the given name, thereby assuming it is a branch.Exceptionpublic TestRepository.CommitBuilder amend(AnyObjectId id) throws Exception
id - the id of the commit to amend.Exceptionpublic <T extends AnyObjectId> T update(String ref, T obj) throws Exception
T - type of the target object.ref - the name of the reference to update to. If ref does
            not start with refs/ and is not the magic names
            HEAD FETCH_HEAD or MERGE_HEAD, then
            refs/heads/ will be prefixed in front of the given
            name, thereby assuming it is a branch.obj - the target object.Exceptionpublic void delete(String ref) throws Exception
ref - the name of the reference to delete. This is normalized
              in the same way as update(String, AnyObjectId).Exceptionpublic void reset(AnyObjectId id) throws Exception
id - ID of detached head.Exceptionreset(String)public void reset(String name) throws Exception
 This is equivalent to git reset --soft in that it modifies HEAD but
 not the index or the working tree of a non-bare repository.
name - revision string; either an existing ref name, or something that
            can be parsed to an object ID.Exceptionpublic RevCommit cherryPick(AnyObjectId id) throws Exception
 This differs from git cherry-pick in that it works in a bare
 repository. As a result, any merge failure results in an exception, as
 there is no way to recover.
id - commit-ish to cherry-pick.Exceptionpublic void updateServerInfo()
                      throws Exception
Exceptionpublic <T extends RevObject> T parseBody(T object) throws Exception
public TestRepository.BranchBuilder branch(String ref)
ref - name of the branch to be constructed. If ref does not
            start with refs/ the prefix refs/heads/ will
            be added.public ObjectId lightweightTag(String name, ObjectId obj) throws Exception
name - the tag name. The /refs/tags/ prefix will be added if the name
            doesn't start with itobj - the object to tagExceptionpublic void fsck(RevObject... tips) throws MissingObjectException, IncorrectObjectTypeException, IOException
This method completes silently if the checks pass. A temporary revision pool is constructed during the checking.
tips - the tips to start checking from; if not supplied the refs of
            the repository are used instead.MissingObjectExceptionIncorrectObjectTypeExceptionIOExceptionCopyright © 2016 Eclipse JGit Project. All rights reserved.