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.
|
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.
|
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.
|
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 |
getClock() |
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
getClock() . |
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 TestRepository(R db) throws IOException
db
- the test repository to write into.IOException
public TestRepository(R db, RevWalk rw) throws IOException
db
- the test repository to write into.rw
- the RevObject pool to use for object lookup.IOException
public R getRepository()
public RevWalk getRevWalk()
public Git git()
public TimeZone getTimeZone()
public void tick(int secDelta)
secDelta
- number of seconds to add to the current time.public void setAuthorAndCommitter(CommitBuilder c)
getClock()
.c
- the commit builder to store.public RevBlob blob(String content) throws Exception
content
- file content, will be UTF-8 encoded.Exception
public RevBlob blob(byte[] content) throws Exception
content
- binary file content.Exception
public DirCacheEntry file(String path, RevBlob blob) throws Exception
path
- path of the file.blob
- a blob, previously constructed in the repository.Exception
public 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.Exception
public RevObject get(RevTree tree, String path) throws Exception
tree
- the tree to search.path
- the path to find the entry of.Exception
public 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.Exception
public RevCommit commit(RevTree tree, RevCommit... parents) throws Exception
tree
- the root tree for the commit.parents
- zero or more parents of the commit.Exception
public 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.Exception
public 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.Exception
public 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.Exception
public TestRepository.CommitBuilder amend(AnyObjectId id) throws Exception
id
- the id of the commit to amend.Exception
public <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.Exception
public void reset(AnyObjectId id) throws Exception
id
- ID of detached head.Exception
reset(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.Exception
public 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.Exception
public void updateServerInfo() throws Exception
Exception
public <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 tagException
public 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.MissingObjectException
IncorrectObjectTypeException
IOException
Copyright © 2015 Eclipse JGit Project. All rights reserved.