本文整理汇总了Java中org.eclipse.jgit.dircache.DirCache.read方法的典型用法代码示例。如果您正苦于以下问题:Java DirCache.read方法的具体用法?Java DirCache.read怎么用?Java DirCache.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.dircache.DirCache
的用法示例。
在下文中一共展示了DirCache.read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareTreeParser
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private AbstractTreeIterator prepareTreeParser(Repository repository, String ref) throws IOException {
if ("~~staged~~".equals(ref)) {
return new DirCacheIterator(DirCache.read(repository));
} else if ("~~unstaged~~".equals(ref)) {
return new FileTreeIterator(repository);
}
try (RevWalk walk = new RevWalk(repository)) {
ObjectId commitObjectId = repository.resolve(ref);
if (commitObjectId == null) {
throw new GitInvalidRefException(format("invalid git ref %s", ref));
}
log.debug("ref: {}, commit id: {}", ref, commitObjectId.toString());
RevCommit commit = walk.parseCommit(commitObjectId);
RevTree tree = walk.parseTree(commit.getTree().getId());
CanonicalTreeParser treeParser = new CanonicalTreeParser();
try (ObjectReader objectReader = repository.newObjectReader()) {
treeParser.reset(objectReader, tree.getId());
}
return treeParser;
}
}
示例2: getProjectList
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public List<String> getProjectList(String projectName){
FileRepositoryBuilder builder = new FileRepositoryBuilder();
List list= new ArrayList();
try {
log.debug("errororororoor123 "+ "\n");
Repository repository = builder
.readEnvironment() // scan environment GIT_* variables
.setGitDir(new File("C:/test0101/" + projectName +"/.git")) // scan up the file system tree
.build();
DirCache index = DirCache.read(repository);
ObjectLoader loader = null;
log.debug("DirCache has " + index.getEntryCount() + " items");
for (int i = 0; i < index.getEntryCount(); i++) {
log.debug(index.getEntry(i).getPathString()+ "\n");
list.add(index.getEntry(i).getPathString());
}
} catch (IOException e) {
log.debug("errororororoor "+ "\n");
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
示例3: main
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// DirCache contains all files of the repository
DirCache index = DirCache.read(repository);
System.out.println("DirCache has " + index.getEntryCount() + " items");
for (int i = 0; i < index.getEntryCount(); i++) {
// the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry
System.out.println("Item " + i + ": " + index.getEntry(i));
}
//
System.out.println("Now printing staged items...");
for (int i = 0; i < index.getEntryCount(); i++) {
DirCacheEntry entry = index.getEntry(i);
if (entry.getStage() != DirCacheEntry.STAGE_0) {
System.out.println("Item " + i + ": " + entry);
}
}
}
}
示例4: getSource
import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public String getSource(String projectName, String path) throws UnsupportedEncodingException{
FileRepositoryBuilder builder = new FileRepositoryBuilder();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
List list= new ArrayList();
HashMap<String, ObjectId> map = new HashMap<String, ObjectId>();
ObjectLoader loader = null;
try {
Repository repository = builder
.readEnvironment() // scan environment GIT_* variables
.setGitDir(new File("C:/test0101/" + projectName +"/.git")) // scan up the file system tree
.build();
DirCache index = DirCache.read(repository);
log.debug("DirCache has " + index.getEntryCount() + " items");
for (int i = 0; i < index.getEntryCount(); i++) {
// log.debug(index.getEntry(i).getPathString()+ "\n");
list.add(index.getEntry(i).getPathString());
map.put(index.getEntry(i).getPathString(),index.getEntry(i).getObjectId() );
}
for(int i =0 ; i< list.size(); i++)
{
//log.debug("********** baos test : " + list.get(i)+ "\n");
// log.debug("********** baos test : " + path+ "\n");
if (list.get(i).equals(path))
{
loader = repository.open(map.get(path));
loader.copyTo(baos);
// log.debug("********** baos test : " + baos.toString()+ "\n");
//loader.copyTo(System.out);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return baos.toString();
}