use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseTag.
@Test
public void parseTag() throws Exception {
RevCommit master = repo.branch("master").commit().create();
RevTag masterTag = repo.update("refs/tags/master-tag", repo.tag("master-tag", master));
RevTag masterTagTag = repo.update("refs/tags/master-tag-tag", repo.tag("master-tag-tag", master));
assertThat(parser.parse("master-tag")).isEqualTo(new Result(new Revision("master-tag", masterTag, OBJ_TAG, master, OBJ_COMMIT)));
assertThat(parser.parse("master-tag-tag")).isEqualTo(new Result(new Revision("master-tag-tag", masterTagTag, OBJ_TAG, master, OBJ_COMMIT)));
RevBlob blob = repo.update("refs/tags/blob", repo.blob("blob"));
RevTag blobTag = repo.update("refs/tags/blob-tag", repo.tag("blob-tag", blob));
assertThat(parser.parse("blob")).isEqualTo(new Result(Revision.peeled("blob", blob)));
assertThat(parser.parse("blob-tag")).isEqualTo(new Result(new Revision("blob-tag", blobTag, OBJ_TAG, blob, OBJ_BLOB)));
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class PathServletTest method symlinkText.
@Test
public void symlinkText() throws Exception {
final RevBlob link = repo.blob("foo");
repo.branch("master").commit().edit(new PathEdit("baz") {
@Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.SYMLINK);
ent.setObjectId(link);
}
}).create();
String text = buildBlob("/repo/+/master/baz", "120000");
assertThat(text).isEqualTo("foo");
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class PathServletTest method treeText.
@Test
public void treeText() throws Exception {
RevBlob blob = repo.blob("contents");
RevTree tree = repo.tree(repo.file("foo/bar", blob));
repo.branch("master").commit().setTopLevelTree(tree).create();
String expected = "040000 tree " + repo.get(tree, "foo").name() + "\tfoo\n";
assertThat(buildBlob("/repo/+/master/", "040000")).isEqualTo(expected);
expected = "100644 blob " + blob.name() + "\tbar\n";
assertThat(buildBlob("/repo/+/master/foo", "040000")).isEqualTo(expected);
assertThat(buildBlob("/repo/+/master/foo/", "040000")).isEqualTo(expected);
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class PathServletTest method fileJson.
@Test
public void fileJson() throws Exception {
RevBlob blob = repo.blob("contents");
repo.branch("master").commit().add("path/to/file", blob).create();
File file = buildJson(File.class, "/repo/+/master/path/to/file");
assertThat(file.id).isEqualTo(blob.name());
assertThat(file.repo).isEqualTo("repo");
assertThat(file.revision).isEqualTo("master");
assertThat(file.path).isEqualTo("path/to/file");
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class PathServletTest method symlinkHtml.
@Test
public void symlinkHtml() throws Exception {
final RevBlob link = repo.blob("foo");
repo.branch("master").commit().add("foo", "contents").edit(new PathEdit("bar") {
@Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.SYMLINK);
ent.setObjectId(link);
}
}).create();
Map<String, ?> data = buildData("/repo/+/master/bar");
assertThat(data).containsEntry("type", "SYMLINK");
assertThat(getBlobData(data)).containsEntry("target", "foo");
}
Aggregations