当前位置: 首页>>代码示例>>Java>>正文


Java DirCache.read方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:27,代码来源:GitManagerImpl.java

示例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;
       
}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:27,代码来源:GitUtils.java

示例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);
            }
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:21,代码来源:ListIndex.java

示例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();
      
}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:47,代码来源:GitUtils.java


注:本文中的org.eclipse.jgit.dircache.DirCache.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。