use of org.eclipse.jgit.revwalk.RevBlob in project gitblit by gitblit.
the class JGitUtils method getByteContent.
/**
* Gets the raw byte content of the specified blob object.
*
* @param repository
* @param objectId
* @return byte [] blob content
*/
public static byte[] getByteContent(Repository repository, String objectId) {
RevWalk rw = new RevWalk(repository);
byte[] content = null;
try {
RevBlob blob = rw.lookupBlob(ObjectId.fromString(objectId));
ObjectLoader ldr = repository.open(blob.getId(), Constants.OBJ_BLOB);
content = ldr.getCachedBytes();
} catch (Throwable t) {
error(t, repository, "{0} can't find blob {1}", objectId);
} finally {
rw.dispose();
}
return content;
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class PathServletTest method treeTextEscaped.
@Test
public void treeTextEscaped() throws Exception {
RevBlob blob = repo.blob("contents");
repo.branch("master").commit().add("foo\nbar\rbaz", blob).create();
assertThat(buildBlob("/repo/+/master/", "040000")).isEqualTo("100644 blob " + blob.name() + "\t\"foo\\nbar\\rbaz\"\n");
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class RevisionParserTest method parseUnsupportedRevisionExpressions.
@Test
public void parseUnsupportedRevisionExpressions() throws Exception {
RevBlob blob = repo.blob("blob contents");
RevCommit master = repo.branch("master").commit().add("blob", blob).create();
assertThat(repo.getRepository().resolve("master^{}")).isEqualTo(master);
assertThat(parser.parse("master^{}")).isNull();
assertThat(repo.getRepository().resolve("master^{commit}")).isEqualTo(master);
assertThat(parser.parse("master^{commit}")).isNull();
assertThat(repo.getRepository().resolve("master:blob")).isEqualTo(blob);
assertThat(parser.parse("master:blob")).isNull();
// TestRepository has no simple way of setting the reflog.
//assertThat(repo.getRepository().resolve("master@{0}")).isEqualTo(null);
assertThat(parser.parse("master@{0}")).isNull();
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class TimeCacheTest method taggedTreeAndBlobTime.
@Test
public void taggedTreeAndBlobTime() throws Exception {
RevBlob blob = repo.blob("contents");
RevTree tree = repo.tree(repo.file("foo", blob));
repo.tick(1);
RevTag blobTag = repo.tag("blob", blob);
repo.tick(1);
RevTag treeTag = repo.tag("tree", tree);
assertThat(getTime(blobTag)).isEqualTo(start + 1);
assertThat(getTime(treeTag)).isEqualTo(start + 2);
}
use of org.eclipse.jgit.revwalk.RevBlob in project gitiles by GerritCodeReview.
the class TimeCacheTest method treeAndBlobTime.
@Test
public void treeAndBlobTime() throws Exception {
RevBlob blob = repo.blob("contents");
RevTree tree = repo.tree(repo.file("foo", blob));
assertThat(getTime(blob)).isEqualTo(Long.MIN_VALUE);
assertThat(getTime(tree)).isEqualTo(Long.MIN_VALUE);
}
Aggregations