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


Java CanonicalTreeParser.reset方法代碼示例

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


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

示例1: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException {
    // from the commit we can build the tree which allows us to construct the TreeParser
    //noinspection Duplicates
    try (RevWalk walk = new RevWalk(repository)) {
        RevCommit commit = walk.parseCommit(ObjectId.fromString(objectId));
        RevTree tree = walk.parseTree(commit.getTree().getId());

        CanonicalTreeParser oldTreeParser = new CanonicalTreeParser();
        try (ObjectReader oldReader = repository.newObjectReader()) {
            oldTreeParser.reset(oldReader, tree.getId());
        }

        walk.dispose();

        return oldTreeParser;
    }
}
 
開發者ID:iazarny,項目名稱:gitember,代碼行數:18,代碼來源:GitRepositoryService.java

示例2: getIterator

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private AbstractTreeIterator getIterator (String commit, ObjectReader or) throws IOException, GitException {
    Repository repository = getRepository();
    switch (commit) {
        case Constants.HEAD:
            return getHeadIterator(or);
        case GitClient.INDEX:
            return new DirCacheIterator(repository.readDirCache());
        case GitClient.WORKING_TREE:
            return new FileTreeIterator(repository);
        default:
            CanonicalTreeParser p = new CanonicalTreeParser();
            p.reset(or, Utils.findCommit(repository, commit).getTree());
            return p;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ExportDiffCommand.java

示例3: blockingPreviewDiff

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private Map<String, Change<?>> blockingPreviewDiff(Revision baseRevision, Iterable<Change<?>> changes) {
    requireNonNull(baseRevision, "baseRevision");
    requireNonNull(changes, "changes");
    baseRevision = blockingNormalize(baseRevision);

    try (ObjectReader reader = jGitRepository.newObjectReader();
         RevWalk revWalk = new RevWalk(reader);
         DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE)) {

        final ObjectId baseTreeId = toTreeId(revWalk, baseRevision);
        final DirCache dirCache = DirCache.newInCore();
        final int numEdits = applyChanges(baseRevision, baseTreeId, dirCache, changes);
        if (numEdits == 0) {
            return Collections.emptyMap();
        }

        CanonicalTreeParser p = new CanonicalTreeParser();
        p.reset(reader, baseTreeId);
        diffFormatter.setRepository(jGitRepository);
        List<DiffEntry> result = diffFormatter.scan(p, new DirCacheIterator(dirCache));
        return toChangeMap(result);
    } catch (IOException e) {
        throw new StorageException("failed to perform a dry-run diff", e);
    }
}
 
開發者ID:line,項目名稱:centraldogma,代碼行數:26,代碼來源:GitRepository.java

示例4: getTreeIterator

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private AbstractTreeIterator getTreeIterator( String commitId ) throws Exception {
  if ( commitId == null ) {
    return new EmptyTreeIterator();
  }
  if ( commitId.equals( WORKINGTREE ) ) {
    return new FileTreeIterator( git.getRepository() );
  } else if ( commitId.equals( INDEX ) ) {
    return new DirCacheIterator( git.getRepository().readDirCache() );
  } else {
    ObjectId id = git.getRepository().resolve( commitId );
    if ( id == null ) { // commitId does not exist
      return new EmptyTreeIterator();
    } else {
      CanonicalTreeParser treeIterator = new CanonicalTreeParser();
      try ( RevWalk rw = new RevWalk( git.getRepository() ) ) {
        RevTree tree = rw.parseTree( id );
        try ( ObjectReader reader = git.getRepository().newObjectReader() ) {
          treeIterator.reset( reader, tree.getId() );
        }
      }
      return treeIterator;
    }
  }
}
 
開發者ID:HiromuHota,項目名稱:pdi-git-plugin,代碼行數:25,代碼來源:UIGit.java

示例5: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的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

示例6: name

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
@Test public void name() throws IOException, GitAPIException {
    ObjectId head = repo.resolve("HEAD^{tree}");
    ObjectId oldHead = repo.resolve("HEAD^^{tree}");


    ObjectReader reader = repo.newObjectReader();

    CanonicalTreeParser prevParser = new CanonicalTreeParser();
    prevParser.reset(reader, oldHead);

    CanonicalTreeParser headParser = new CanonicalTreeParser();
    headParser.reset(reader, head);

    List<DiffEntry> diffs = new Git(repo).diff()
            .setNewTree(headParser)
            .setOldTree(prevParser)
            .call();

    for (DiffEntry entry : diffs)
        System.out.println(entry);
}
 
開發者ID:SourcePond,項目名稱:release-maven-plugin-parent,代碼行數:22,代碼來源:JGitDiscoveryTest.java

示例7: processTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private void processTreeParser(CanonicalTreeParser treeParser)
		throws IOException {
	TreeParserTreeEntry treeParserEntry = new TreeParserTreeEntry(
			treeParser, objectReader);

	List<CanonicalTreeParser> subTrees = new ArrayList<CanonicalTreeParser>();
	while (!treeParser.eof()) {
		FileMode entryFileMode = treeParser.getEntryFileMode();
		if (FileMode.TREE.equals(entryFileMode)) {
			CanonicalTreeParser canonicalTreeParser = new CanonicalTreeParser();
			canonicalTreeParser.reset(objectReader,
					treeParser.getEntryObjectId());
			subTrees.add(canonicalTreeParser);
		} else {
			if (!filterPredicate.evaluate(treeParserEntry)) {
				treeEntryWalk.walk(treeParserEntry);
			}
		}
		treeParser.next();
	}
	for (CanonicalTreeParser subTreeParser : subTrees) {
		processTreeParser(subTreeParser);
	}
}
 
開發者ID:link-intersystems,項目名稱:GitDirStat,代碼行數:25,代碼來源:TreeParserTreeEntryWalkAdapter.java

示例8: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private AbstractTreeIterator prepareTreeParser(Repository repo, Ref targetRef) throws IOException {
  try (RevWalk walk = newRevWalk(repo)) {
    walk.markStart(walk.parseCommit(targetRef.getObjectId()));
    walk.markStart(walk.parseCommit(repo.exactRef("HEAD").getObjectId()));
    walk.setRevFilter(RevFilter.MERGE_BASE);
    RevCommit base = walk.parseCommit(walk.next());

    CanonicalTreeParser treeParser = new CanonicalTreeParser();
    try (ObjectReader objectReader = repo.newObjectReader()) {
      treeParser.reset(objectReader, base.getTree());
    }

    walk.dispose();

    return treeParser;
  }
}
 
開發者ID:SonarSource,項目名稱:sonar-scm-git,代碼行數:18,代碼來源:GitScmProvider.java

示例9: emptyToCommit

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
/**
 * Show changes between specified revision and empty tree.
 *
 * @param commitId id of commit
 * @param formatter diff formatter
 * @return list of diff entries
 * @throws IOException if any i/o errors occurs
 */
private List<DiffEntry> emptyToCommit(String commitId, DiffFormatter formatter)
    throws IOException {
  ObjectId commit = repository.resolve(commitId);
  checkArgument(commit != null, "Invalid commit id " + commitId);
  RevTree tree;
  try (RevWalk revWalkA = new RevWalk(repository)) {
    tree = revWalkA.parseTree(commit);
  }

  List<DiffEntry> diff;
  try (ObjectReader reader = repository.newObjectReader()) {
    CanonicalTreeParser iterator = new CanonicalTreeParser();
    iterator.reset(reader, tree);
    diff = formatter.scan(new EmptyTreeIterator(), iterator);
  }
  return diff;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:26,代碼來源:JGitDiffPage.java

示例10: execute

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
public List<DiffEntry> execute() {
    if (newRef == null || git.getRepository() == null) {
        return emptyList();
    }

    try (final ObjectReader reader = git.getRepository().newObjectReader()) {
        CanonicalTreeParser oldTreeIter = new CanonicalTreeParser();
        if (oldRef != null) {
            oldTreeIter.reset(reader,
                              oldRef);
        }
        CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
        newTreeIter.reset(reader,
                          newRef);
        return new CustomDiffCommand(git).setNewTree(newTreeIter).setOldTree(oldTreeIter).setShowNameAndStatusOnly(true).call();
    } catch (final Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:20,代碼來源:ListDiffs.java

示例11: populateDiff

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
/**
 * Populate all the files to update, if the system should update.
 */
private void populateDiff() {
    try {
        git.fetch().call();
        Repository repo = git.getRepository();
        ObjectId fetchHead = repo.resolve("FETCH_HEAD^{tree}");
        ObjectId head = repo.resolve("HEAD^{tree}");
        
        ObjectReader reader = repo.newObjectReader();
        CanonicalTreeParser oldTreeIter = new CanonicalTreeParser();
        oldTreeIter.reset(reader, head);
        CanonicalTreeParser newTreeIter = new CanonicalTreeParser();
        newTreeIter.reset(reader, fetchHead);
        List<DiffEntry> diffs = git.diff().setShowNameAndStatusOnly(true)
                .setNewTree(newTreeIter)
                .setOldTree(oldTreeIter)
                .call();
        
        pluginsToUpdate = new ArrayList<PluginToUpdate>();
        
        checkDiffEmpty(diffs);
        
    } catch (GitAPIException | IOException ex) {
        Logger.getLogger(UpdaterGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:Neembuu-Uploader,項目名稱:neembuu-uploader,代碼行數:29,代碼來源:UpdaterGenerator.java

示例12: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private static AbstractTreeIterator prepareTreeParser(
		Repository repository, RevCommit commit) throws IOException,
		MissingObjectException, IncorrectObjectTypeException {
	// from the commit we can build the tree which allows us to construct
	// the TreeParser
	RevWalk walk = new RevWalk(repository);
	RevTree tree = walk.parseTree(commit.getTree().getId());
	CanonicalTreeParser result = new CanonicalTreeParser();
	ObjectReader reader = repository.newObjectReader();
	try {
		result.reset(reader, tree.getId());
	} finally {
		reader.release();
	}
	walk.dispose();
	return result;
}
 
開發者ID:DrDub,項目名稱:gitrecommender,代碼行數:18,代碼來源:UpdateLog.java

示例13: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException {
    // from the commit we can build the tree which allows us to construct the TreeParser
    //noinspection Duplicates
    try (RevWalk walk = new RevWalk(repository)) {
        RevCommit commit = walk.parseCommit(repository.resolve(objectId));
        RevTree tree = walk.parseTree(commit.getTree().getId());

        CanonicalTreeParser treeParser = new CanonicalTreeParser();
        try (ObjectReader reader = repository.newObjectReader()) {
            treeParser.reset(reader, tree.getId());
        }

        walk.dispose();

        return treeParser;
    }
}
 
開發者ID:centic9,項目名稱:jgit-cookbook,代碼行數:18,代碼來源:DiffFilesInCommit.java

示例14: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException {
    // from the commit we can build the tree which allows us to construct the TreeParser
    //noinspection Duplicates
    try (RevWalk walk = new RevWalk(repository)) {
        RevCommit commit = walk.parseCommit(ObjectId.fromString(objectId));
        RevTree tree = walk.parseTree(commit.getTree().getId());

        CanonicalTreeParser treeParser = new CanonicalTreeParser();
        try (ObjectReader reader = repository.newObjectReader()) {
            treeParser.reset(reader, tree.getId());
        }

        walk.dispose();

        return treeParser;
    }
}
 
開發者ID:centic9,項目名稱:jgit-cookbook,代碼行數:18,代碼來源:ShowFileDiff.java

示例15: prepareTreeParser

import org.eclipse.jgit.treewalk.CanonicalTreeParser; //導入方法依賴的package包/類
private static AbstractTreeIterator prepareTreeParser(Repository repository, String ref) throws IOException {
    // from the commit we can build the tree which allows us to construct the TreeParser
    Ref head = repository.exactRef(ref);
    try (RevWalk walk = new RevWalk(repository)) {
        RevCommit commit = walk.parseCommit(head.getObjectId());
        RevTree tree = walk.parseTree(commit.getTree().getId());

        CanonicalTreeParser treeParser = new CanonicalTreeParser();
        try (ObjectReader reader = repository.newObjectReader()) {
            treeParser.reset(reader, tree.getId());
        }

        walk.dispose();

        return treeParser;
    }
}
 
開發者ID:centic9,項目名稱:jgit-cookbook,代碼行數:18,代碼來源:ShowBranchDiff.java


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