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


Java TreeWalk.next方法代码示例

本文整理汇总了Java中org.eclipse.jgit.treewalk.TreeWalk.next方法的典型用法代码示例。如果您正苦于以下问题:Java TreeWalk.next方法的具体用法?Java TreeWalk.next怎么用?Java TreeWalk.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.treewalk.TreeWalk的用法示例。


在下文中一共展示了TreeWalk.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSubmoduleCommitId

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public static String getSubmoduleCommitId(Repository repository, String path, RevCommit commit) {
	String commitId = null;
	RevWalk rw = new RevWalk(repository);
	TreeWalk tw = new TreeWalk(repository);
	tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
	try {
		tw.reset(commit.getTree());
		while (tw.next()) {
			if (tw.isSubtree() && !path.equals(tw.getPathString())) {
				tw.enterSubtree();
				continue;
			}
			if (FileMode.GITLINK == tw.getFileMode(0)) {
				commitId = tw.getObjectId(0).getName();
				break;
			}
		}
	} catch (Throwable t) {
		error(t, repository, "{0} can't find {1} in commit {2}", path, commit.name());
	} finally {
		rw.dispose();
		tw.release();
	}
	return commitId;
}
 
开发者ID:BullShark,项目名称:IRCBlit,代码行数:26,代码来源:JGitUtils.java

示例2: isDirectory

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/** 파일주소와 커밋아이디를 바탕으로 디렉토리인지 검사함.
 * @param commitID
 * @param filePath
 * @return
 */
public boolean isDirectory(String commitID, String filePath){
	if(filePath.length() == 0)
		return true;
	try{
		ObjectId revId = this.localRepo.resolve(commitID);
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(revId));
		treeWalk.setRecursive(true);
		while (treeWalk.next()) {
			if(treeWalk.getPathString().equals(filePath)){
				return false;
			}
		}
		treeWalk.reset(new RevWalk(this.localRepo).parseTree(revId));
		while (treeWalk.next()) {
			if(treeWalk.getPathString().startsWith(filePath)){
				return true;
			}
		}
	}catch(Exception e){
		return false;
	}
	return false;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:30,代码来源:GitUtil.java

示例3: getGitFileList

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/** 저장소의 파일 목록을 커밋 아이디를 가지고 가져옴.
 * @param commitID
 * @return
 */
public List<String> getGitFileList(String commitID) {
	List<String> fileList = new ArrayList<String>();
	try{
		ObjectId revId = this.localRepo.resolve(commitID);
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(revId));
		treeWalk.setRecursive(true);

		while (treeWalk.next()) {
			fileList.add("/"+treeWalk.getPathString());
		}

	}catch(Exception e){
		System.out.println(e.getMessage());
	}
	return fileList;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:22,代码来源:GitUtil.java

示例4: simpleFileBrowser

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/** 단순하게 커밋을 트리워크를 이용하여 당시 파일 내역을 출력.
 * @param commit
 * @return
 */
private String simpleFileBrowser(RevCommit commit){
	String out = new String();
	try
	{
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(	commit));

		while (treeWalk.next())
		{
			out+="--- /dev/null\n";
			out+="+++ b/"+treeWalk.getPathString()+"\n";
			out+= "+"+BlobUtils.getContent(this.localRepo, commit,treeWalk.getPathString().replace("\n", "\n+"));
			out+="\n";
		}
	}finally{
		return out;
	}
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:23,代码来源:GitUtil.java

示例5: getLoaderFrom

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/**
 * Gets the loader for a file from a specified commit and its path
 * 
 * @param commit
 *          - the commit from which to get the loader
 * @param path
 *          - the path to the file
 * @return the loader
 * @throws MissingObjectException
 * @throws IncorrectObjectTypeException
 * @throws CorruptObjectException
 * @throws IOException
 */
public ObjectLoader getLoaderFrom(ObjectId commit, String path)
		throws IOException {
	Repository repository = git.getRepository();
	RevWalk revWalk = new RevWalk(repository);
	RevCommit revCommit = revWalk.parseCommit(commit);
	// and using commit's tree find the path
	RevTree tree = revCommit.getTree();
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.addTree(tree);
	treeWalk.setRecursive(true);
	treeWalk.setFilter(PathFilter.create(path));

	ObjectLoader loader = null;
	if (treeWalk.next()) {
		ObjectId objectId = treeWalk.getObjectId(0);
		loader = repository.open(objectId);
	}

	treeWalk.close();
	revWalk.close();
	return loader;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:36,代码来源:GitAccess.java

示例6: getGitFileList

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/** 프로젝트의 파일 목록을 커밋 아이디를 가지고 가져옴.
 * @param commitID
 * @return
 */
public List<String> getGitFileList(String commitID) {
	List<String> fileList = new ArrayList<String>();
	try{
		ObjectId revId = this.localRepo.resolve(commitID);
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(revId));
		treeWalk.setRecursive(true);

		while (treeWalk.next()) {
			fileList.add("/"+treeWalk.getPathString());
		}

	}catch(Exception e){
		System.out.println(e.getMessage());
	}
	return fileList;
}
 
开发者ID:LandvibeDev,项目名称:codefolio,代码行数:22,代码来源:GitUtils.java

示例7: buildDirCache

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
private void buildDirCache(TreeWalk walk, DirCacheBuilder builder)
		throws MissingObjectException, IncorrectObjectTypeException,
		CorruptObjectException, IOException {
	while (walk.next()) {
		AbstractTreeIterator cIter = walk.getTree(0,
				AbstractTreeIterator.class);
		if (cIter == null) {
			// Not in commit, don't add to new index
			continue;
		}

		final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
		entry.setFileMode(cIter.getEntryFileMode());
		entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());

		DirCacheIterator dcIter = walk.getTree(1, DirCacheIterator.class);
		if (dcIter != null && dcIter.idEqual(cIter)) {
			DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
			entry.setLastModified(indexEntry.getLastModified());
			entry.setLength(indexEntry.getLength());
		}

		builder.add(entry);
	}
}
 
开发者ID:link-intersystems,项目名称:GitDirStat,代码行数:26,代码来源:IndexUpdate.java

示例8: getFileFromCommit

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public static boolean getFileFromCommit(final OutputStream os, final String file, final Repository repo, final RevTree tree) throws IOException, GitAPIException {
    final TreeWalk treeWalk = new TreeWalk(repo);
    treeWalk.addTree(tree);
    treeWalk.setRecursive(true);
    treeWalk.setFilter(PathFilter.create(file));
    if (!treeWalk.next()) {
        logger.info("Did not find expected file '" + file + "'");
        return false;
    }

    final ObjectId objectId = treeWalk.getObjectId(0);
    final ObjectLoader loader = repo.open(objectId);

    // and then one can the loader to read the file
    loader.copyTo(os);
    return true;
}
 
开发者ID:cobr123,项目名称:VirtaMarketAnalyzer,代码行数:18,代码来源:GitHubPublisher.java

示例9: getBlob

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
private Optional<String[]> getBlob(Git git, String fileName, CodeRevision revision)
		throws IOException {
	TreeWalk treeWalk = new TreeWalk(git.getRepository());
	treeWalk.addTree(getTreeIterator(git, revision));
	treeWalk.setFilter(PathFilter.create(fileName));
	treeWalk.setRecursive(true);
	if (!treeWalk.next()) {
		return Optional.empty();
	}
	ObjectId blobId = treeWalk.getObjectId(0);
	String content = new String(git.getRepository().getObjectDatabase().open(blobId).getBytes(),
			Charset.forName("UTF-8"));

	String[] lines = content.split("\n");
	return Optional.of(lines);
}
 
开发者ID:bugminer,项目名称:bugminer,代码行数:17,代码来源:GitStrategy.java

示例10: headFiles

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
/**
 * @return All files in a tree under HEAD ref in this repo.
 */
public Collection<FileInGitWorkingTree> headFiles() {
    final Collection<FileInGitWorkingTree> files =
        new ArrayList<>(WorkingDirectory.ESTIMATED_NUMBER_OF_FILES);
    final TreeWalk walk = new WalkOverRepoHead(this.git.getRepository());
    try {
        while (walk.next()) {
            files.add(
                new FileInGitWorkingTree(
                    this.git,
                    walk.getPathString()
                )
            );
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return files;
}
 
开发者ID:gvlasov,项目名称:git-version-insert-maven-plugin,代码行数:22,代码来源:WorkingDirectory.java

示例11: walksOverRepoHeadTest

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
@Test
public void walksOverRepoHeadTest() throws Exception{
    final TreeWalk walk =
        new WalkOverRepoHead(
            new FakeGitTestRepo()
        );
    Collection<Path> paths = new ArrayList<>();
    while (walk.next()) {
        paths.add(
            Paths.get(walk.getPathString()).getFileName()
        );
    }
    MatcherAssert.assertThat(
        paths,
        Matchers.containsInAnyOrder(
            Paths.get("file1"),
            Paths.get("file2")
        )
    );
}
 
开发者ID:gvlasov,项目名称:git-version-insert-maven-plugin,代码行数:21,代码来源:WalkOverRepoHeadTest.java

示例12: doStatus

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public static SCMStatus doStatus(File baseDir) throws RuntimeException {
    try {
        Map<String, Boolean> map = new HashMap<String, Boolean>();

        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder.setGitDir(new File(baseDir, ".git")).build();
        TreeWalk treeWalk = new TreeWalk(repository);
        treeWalk.addTree(getTree(repository));
        treeWalk.setRecursive(true);
        while (treeWalk.next()) {
            map.put(treeWalk.getPathString(), Boolean.TRUE);
        }

        log.info("-----------------------------------------------------------------------------------------------");
        log.info("PROJECT IS UNDER GIT: Files tracked by git ({}) won't be overwritten/deleted by Celerio", map.size());
        log.info("-----------------------------------------------------------------------------------------------");

        return new SCMStatus(map);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:jaxio,项目名称:celerio,代码行数:23,代码来源:GITStatusCrawler.java

示例13: getFileAsDiffFormat

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public List<DiffInfo> getFileAsDiffFormat(RepositoryPK repositoryPK, String ref) {
  try (RepositoryReader reader = new RepositoryReader(repositoryPK)) {
    Git git = reader.getGit();
    Repository repository = reader.getRepository();

    ObjectId objectId = repository.resolve(ref);
    List<RevCommit> commits = getFirstCommits(git, objectId, null, 2);

    TreeWalk treeWalk = new TreeWalk(repository);
    List<DiffInfo> diffInfos = new ArrayList<>();
    treeWalk.addTree(commits.get(0).getTree());
    treeWalk.setRecursive(true);
    while (treeWalk.next()) {
      ObjectId fileId = treeWalk.getObjectId(0);
      if (!treeWalk.isSubtree()) {
        FileContent fileContent = getFileContent(git, treeWalk.getPathString(), fileId);
        diffInfos.add(DiffInfo.ofNewCommit(fileContent));
      }
    }
    return diffInfos;
  } catch (IOException | GitAPIException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:kamegu,项目名称:git-webapp,代码行数:25,代码来源:GitOperation.java

示例14: setObject

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public void setObject(RevTree tree, View view, Repository repo) {
    TreeWalk treeWalk = new TreeWalk(repo);
    StringBuilder sb = new StringBuilder();
    try {
        int treeIndex = treeWalk.addTree(tree);
        while (treeWalk.next()) {
            ObjectId newObjectId = treeWalk.getObjectId(treeIndex);
            String rawPath = new String(treeWalk.getRawPath());
            sb.append(rawPath).append(" - ");
            //System.out.println(newObjectId+" rawPath="+rawPath+" subTree="+ tw.isSubtree());
        }
        ((TextView) view.findViewById(R.id.osv_tree_description)).setText(sb);
    } catch (Exception e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:17,代码来源:TreeSummaryView.java

示例15: gitRepoContainsFile

import org.eclipse.jgit.treewalk.TreeWalk; //导入方法依赖的package包/类
public static boolean gitRepoContainsFile(Repository repository, String file) throws IllegalStateException, IOException {
	ObjectId lastCommitId = repository.resolve(Constants.HEAD);

       // a RevWalk allows to walk over commits based on some filtering
       RevWalk revWalk = new RevWalk(repository);
       RevCommit commit = revWalk.parseCommit(lastCommitId);

       // and using commit's tree find the path
       RevTree tree = commit.getTree();
       
       TreeWalk treeWalk = new TreeWalk(repository);
       treeWalk.addTree(tree);
       treeWalk.setRecursive(true);
       treeWalk.setFilter(PathFilter.create(file));
       return treeWalk.next(); 
}
 
开发者ID:jenkinsci,项目名称:openshift-deployer-plugin,代码行数:17,代码来源:TestUtils.java


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