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


Java RevCommit.getTree方法代碼示例

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


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

示例1: checkJGitFix

import org.eclipse.jgit.revwalk.RevCommit; //導入方法依賴的package包/類
private void checkJGitFix (String branch, File file) throws Exception {
    ObjectId headTree = null;
    try {
        headTree = Utils.findCommit(repository, Constants.HEAD).getTree();
    } catch (GitException.MissingObjectException ex) { }

    DirCache cache = repository.lockDirCache();
    RevCommit commit;
    commit = Utils.findCommit(repository, branch);
    DirCacheCheckout dco = new DirCacheCheckout(repository, headTree, cache, commit.getTree());
    dco.setFailOnConflict(false);
    dco.checkout();
    if (file.exists()) {
        // and do not forget to remove WA in checkout command when JGit is fixed.
        fail("Hey, JGit is fixed, why don't you fix me as well?");
    }
    cache.unlock();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:CheckoutTest.java

示例2: getLoaderFrom

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

示例3: getTree

import org.eclipse.jgit.revwalk.RevCommit; //導入方法依賴的package包/類
private static RevTree getTree(Repository repository) throws IOException {
    ObjectId lastCommitId = repository.resolve(Constants.HEAD);

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

        System.out.println("Time of commit (seconds since epoch): " + commit.getCommitTime());

        // and using commit's tree find the path
        RevTree tree = commit.getTree();
        System.out.println("Having tree: " + tree);
        return tree;
    }
}
 
開發者ID:alexmy21,項目名稱:gmds,代碼行數:16,代碼來源:GetFileAttributes.java

示例4: getRevTree

import org.eclipse.jgit.revwalk.RevCommit; //導入方法依賴的package包/類
private RevTree getRevTree() throws IOException {
    Ref ref = repository.exactRef(branch.getFullRef());
    RevCommit commit = new RevWalk(repository).parseCommit(ref.getObjectId());
    return commit.getTree();
}
 
開發者ID:berlam,項目名稱:github-bucket,代碼行數:6,代碼來源:RepositoryS3.java

示例5: getCommit

import org.eclipse.jgit.revwalk.RevCommit; //導入方法依賴的package包/類
/**
 * Returns the SHA-1 commit id for a file by specifying what commit to get for
 * that file and it's path
 * 
 * @param commit
 *          - specifies the commit to return(MINE, THEIRS, BASE, LOCAL)
 * @param path
 *          - the file path for the specified commit
 * @return the SHA-1 commit id
 */
public ObjectId getCommit(Commit commit, String path) {
	List<DiffEntry> entries;
	boolean baseIsNull = false;
	int index = 0;
	try {
		entries = git.diff().setPathFilter(PathFilter.create(path)).call();
		if (entries.size() == 2) {
			baseIsNull = true;
		}
		if (commit == Commit.MINE) {
			if (baseIsNull) {
				index = 0;
			} else {
				index = 1;
			}
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.THEIRS) {
			if (baseIsNull) {
				index = 1;
			} else {
				index = 2;
			}
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.BASE) {
			return entries.get(index).getOldId().toObjectId();
		} else if (commit == Commit.LOCAL) {
			ObjectId lastLocalCommit = getLastLocalCommit();
			RevWalk revWalk = new RevWalk(git.getRepository());
			RevCommit revCommit = revWalk.parseCommit(lastLocalCommit);
			RevTree tree = revCommit.getTree();
			TreeWalk treeWalk = new TreeWalk(git.getRepository());
			treeWalk.addTree(tree);
			treeWalk.setRecursive(true);
			treeWalk.setFilter(PathFilter.create(path));
			ObjectId objectId = null;
			if (treeWalk.next()) {
				objectId = treeWalk.getObjectId(0);
			}
			treeWalk.close();
			revWalk.close();
			return objectId;
		}
	} catch (GitAPIException |IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	return null;
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:60,代碼來源:GitAccess.java


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