當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeWalk.addTree方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.treewalk.TreeWalk.addTree方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeWalk.addTree方法的具體用法?Java TreeWalk.addTree怎麽用?Java TreeWalk.addTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.treewalk.TreeWalk的用法示例。


在下文中一共展示了TreeWalk.addTree方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: iterator

import org.eclipse.jgit.treewalk.TreeWalk; //導入方法依賴的package包/類
@Override
public Iterator<TreeWalkerEntry> iterator() {
	Repository repository = commit.getGitRepository().getRepository();
	TreeWalk treeWalk = new TreeWalk(repository);
	treeWalk.setRecursive(true);
	RevTree tree = getCommit().getRevCommit().getTree();
	try {
		treeWalk.addTree(tree);
		TreeWalkerIterator treeWalkerIterator = new TreeWalkerIterator(
				treeWalk, this);
		iterators.add(treeWalkerIterator);
		return treeWalkerIterator;
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:17,代碼來源:TreeWalker.java

示例7: 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

示例8: addTree

import org.eclipse.jgit.treewalk.TreeWalk; //導入方法依賴的package包/類
private int addTree(int mode, Shell shell, Repository rep, RevWalk rw, TreeWalk tw) throws Exception {
	int index = -1;
	switch (mode) {
	case GitModeMenuMgr.MODE_STAGING:
		tw.addTree(new DirCacheIterator(rep.readDirCache()));
		break;
	case GitModeMenuMgr.MODE_OTHERS://choose a GIT ref
		CompareTargetSelectionDialog dialog = new CompareTargetSelectionDialog(shell, rep, null);
		if (dialog.open() != CompareTargetSelectionDialog.OK) {
			return -2;
		}
		ObjectId obId = rep.getRef(dialog.getRefName()).getObjectId();//"master"
		tw.addTree(rw.parseCommit(obId).getTree());
		break;
	case GitModeMenuMgr.MODE_BRANCH_HEAD:
		Ref head = rep.getRef(Constants.HEAD);
		RevCommit rc = rw.parseCommit(head.getObjectId());
		tw.addTree(rc.getTree());
		break;
	default://compare to working area
		index = tw.addTree(new FileTreeIterator(rep));
		break;
	}
	return index;
}
 
開發者ID:BeckYang,項目名稱:TeamFileList,代碼行數:26,代碼來源:GitListBuilder.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: 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

示例11: 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

示例12: 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

示例13: 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

示例14: collectRename

import org.eclipse.jgit.treewalk.TreeWalk; //導入方法依賴的package包/類
@NotNull
private Map<String, String> collectRename(@NotNull GitFile oldTree, @NotNull GitFile newTree) throws IOException {
  if (!renameDetection) {
    return Collections.emptyMap();
  }
  final GitObject<ObjectId> oldTreeId = oldTree.getObjectId();
  final GitObject<ObjectId> newTreeId = newTree.getObjectId();
  if (oldTreeId == null || newTreeId == null || !Objects.equals(oldTreeId.getRepo(), newTreeId.getRepo())) {
    return Collections.emptyMap();
  }
  final TreeWalk tw = new TreeWalk(repository);
  tw.setRecursive(true);
  tw.addTree(oldTree.getObjectId().getObject());
  tw.addTree(newTree.getObjectId().getObject());

  final RenameDetector rd = new RenameDetector(repository);
  rd.addAll(DiffEntry.scan(tw));

  final Map<String, String> result = new HashMap<>();
  for (DiffEntry diff : rd.compute(tw.getObjectReader(), null)) {
    if (diff.getScore() >= rd.getRenameScore()) {
      result.put(StringHelper.normalize(diff.getNewPath()), StringHelper.normalize(diff.getOldPath()));
    }
  }
  return result;
}
 
開發者ID:bozaro,項目名稱:git-as-svn,代碼行數:27,代碼來源:GitRepository.java

示例15: listFiles

import org.eclipse.jgit.treewalk.TreeWalk; //導入方法依賴的package包/類
private void listFiles() throws GitException {
    RevWalk revWalk = new RevWalk(repository);
    TreeWalk walk = new TreeWalk(repository);
    try {
        List<GitFileInfo> result;
        walk.reset();
        walk.setRecursive(true);
        RevCommit parentCommit = null;
        if (revCommit.getParentCount() > 0) {
            for (RevCommit commit : revCommit.getParents()) {
                revWalk.markStart(revWalk.lookupCommit(commit));
            }
            revWalk.setRevFilter(RevFilter.MERGE_BASE);
            Iterator<RevCommit> it = revWalk.iterator();
            if (it.hasNext()) {
                parentCommit = it.next();
            }
            if (parentCommit != null) {
                walk.addTree(parentCommit.getTree().getId());
            }
        }
        walk.addTree(revCommit.getTree().getId());
        walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilter.ANY_DIFF));
        if (parentCommit != null) {
            result = Utils.getDiffEntries(repository, walk, GitClassFactoryImpl.getInstance());
        } else {
            result = new ArrayList<GitFileInfo>();
            while (walk.next()) {
                result.add(new GitFileInfo(new File(repository.getWorkTree(), walk.getPathString()), walk.getPathString(), GitFileInfo.Status.ADDED, null, null));
            }
        }
        this.modifiedFiles = result.toArray(new GitFileInfo[result.size()]);
    } catch (IOException ex) {
        throw new GitException(ex);
    } finally {
        revWalk.release();
        walk.release();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:GitRevisionInfo.java


注:本文中的org.eclipse.jgit.treewalk.TreeWalk.addTree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。