Search in sources :

Example 1 with RevBlob

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)));
}
Also used : RevTag(org.eclipse.jgit.revwalk.RevTag) RevBlob(org.eclipse.jgit.revwalk.RevBlob) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Result(com.google.gitiles.RevisionParser.Result) Test(org.junit.Test)

Example 2 with RevBlob

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");
}
Also used : DirCacheEntry(org.eclipse.jgit.dircache.DirCacheEntry) RevBlob(org.eclipse.jgit.revwalk.RevBlob) PathEdit(org.eclipse.jgit.dircache.DirCacheEditor.PathEdit) Test(org.junit.Test)

Example 3 with RevBlob

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);
}
Also used : RevBlob(org.eclipse.jgit.revwalk.RevBlob) RevTree(org.eclipse.jgit.revwalk.RevTree) Test(org.junit.Test)

Example 4 with RevBlob

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");
}
Also used : RevBlob(org.eclipse.jgit.revwalk.RevBlob) File(com.google.gitiles.FileJsonData.File) Test(org.junit.Test)

Example 5 with RevBlob

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");
}
Also used : DirCacheEntry(org.eclipse.jgit.dircache.DirCacheEntry) RevBlob(org.eclipse.jgit.revwalk.RevBlob) PathEdit(org.eclipse.jgit.dircache.DirCacheEditor.PathEdit) Test(org.junit.Test)

Aggregations

RevBlob (org.eclipse.jgit.revwalk.RevBlob)10 Test (org.junit.Test)9 RevTree (org.eclipse.jgit.revwalk.RevTree)3 PathEdit (org.eclipse.jgit.dircache.DirCacheEditor.PathEdit)2 DirCacheEntry (org.eclipse.jgit.dircache.DirCacheEntry)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 RevTag (org.eclipse.jgit.revwalk.RevTag)2 File (com.google.gitiles.FileJsonData.File)1 Result (com.google.gitiles.RevisionParser.Result)1 ObjectLoader (org.eclipse.jgit.lib.ObjectLoader)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1