本文整理汇总了Java中org.eclipse.jgit.lib.ObjectLoader.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectLoader.getBytes方法的具体用法?Java ObjectLoader.getBytes怎么用?Java ObjectLoader.getBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.ObjectLoader
的用法示例。
在下文中一共展示了ObjectLoader.getBytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNote
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
/** 커밋에 붙어있는 GIT 노트를 가져옴
* @param commit
* @return
*/
public String getNote(String commit){
String str = new String();
try{
Note note = git.notesShow().setObjectId(CommitUtils.getCommit(git.getRepository(), commit)).call();
ObjectLoader loader = this.localRepo.open(note.getData());
str = new String(loader.getBytes());
}finally{
return str;
}
}
示例2: getObjectFromRepo
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
/**
*
* @param repo
* @param blobId
* @return
* @throws LargeObjectException
* @throws IOException
*/
public static byte[] getObjectFromRepo(Repository repo, ObjectId blobId) throws LargeObjectException, IOException {
ObjectReader objectReader = repo.newObjectReader();
ObjectLoader objectLoader = objectReader.open(blobId);
// int type = objectLoader.getType(); // Constants.OBJ_BLOB
byte[] bytes = objectLoader.getBytes();
return bytes;
}
示例3: makePack
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
/**
* Function used to treat pack object, it load the data from each object of
* the pack to create the original object when the object is recreate it
* store the object into the git object index
*
* @author Sylvain
*
* @param pathPack
* the path of the pack file
* @throws IOException
* @throws DataFormatException
*/
public static void makePack(String pathPack) throws IOException, DataFormatException {
String[] path = pathPack.split(osBarre + ".git" + osBarre);
RepositoryBuilder builder = new RepositoryBuilder();
builder.setMustExist(true);
builder.setGitDir(new File(path[0] + osBarre + ".git" + osBarre));
Repository repository = builder.build();
for (MutableEntry mutableEntry : new PackFile(new File(pathPack), 0)) {
GitObject obj = null;
String sha1 = mutableEntry.toObjectId().name();
ObjectId id = repository.resolve(sha1);
ObjectLoader loader = repository.open(id);
switch (loader.getType()) {
case Constants.OBJ_BLOB:
obj = new GitBlob(loader.getSize(), sha1, "", loader.getCachedBytes());
break;
case Constants.OBJ_COMMIT:
obj = new GitCommit(loader.getSize(), sha1, new String(loader.getCachedBytes()));
break;
case Constants.OBJ_TREE:
obj = new GitTree(loader.getSize(), sha1, loader.getBytes());
break;
case Constants.OBJ_TAG:
obj = new GitTag(loader.getSize(), sha1, new String(loader.getCachedBytes()));
break;
default:
break;
}
GitObjectsIndex.getInstance().put(mutableEntry.toObjectId().name(), obj);
}
}
示例4: getContent
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
private String getContent(final ObjectId id) {
try {
final ObjectLoader loader = repository.open(id);
return new String(loader.getBytes());
}
catch (final IOException e) {
return EMPTY;
}
}
示例5: showFileContent
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
@Override
public ShowFileContentResponse showFileContent(String file, String version) throws GitException {
String content;
ObjectId revision;
try {
revision = getRepository().resolve(version);
try (RevWalk revWalk = new RevWalk(getRepository())) {
RevCommit revCommit = revWalk.parseCommit(revision);
RevTree tree = revCommit.getTree();
try (TreeWalk treeWalk = new TreeWalk(getRepository())) {
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathFilter.create(file));
if (!treeWalk.next()) {
throw new GitException(
"fatal: Path '" + file + "' does not exist in '" + version + "'" + lineSeparator());
}
ObjectId objectId = treeWalk.getObjectId(0);
ObjectLoader loader = repository.open(objectId);
content = new String(loader.getBytes());
}
}
} catch (IOException exception) {
throw new GitException(exception.getMessage());
}
return newDto(ShowFileContentResponse.class).withContent(content);
}
示例6: open
import org.eclipse.jgit.lib.ObjectLoader; //导入方法依赖的package包/类
private byte[] open(DiffEntry.Side side, DiffEntry entry)
throws IOException {
if (entry.getMode(side) == FileMode.MISSING)
return EMPTY;
if (entry.getMode(side).getObjectType() != Constants.OBJ_BLOB)
return EMPTY;
ObjectLoader ldr = source.open(side, entry);
return ldr.getBytes(binaryFileThreshold);
}