本文整理匯總了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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}