本文整理匯總了Java中org.eclipse.jgit.revwalk.RevCommit.toObjectId方法的典型用法代碼示例。如果您正苦於以下問題:Java RevCommit.toObjectId方法的具體用法?Java RevCommit.toObjectId怎麽用?Java RevCommit.toObjectId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.revwalk.RevCommit
的用法示例。
在下文中一共展示了RevCommit.toObjectId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBaseCommit
import org.eclipse.jgit.revwalk.RevCommit; //導入方法依賴的package包/類
/**
* Finds the base commit from the last local commit and the remote commit
*
* @param branchInfo Current branch info or <code>null</code> if unknown.
*
* @return the base commit
*/
public ObjectId getBaseCommit(BranchInfo branchInfo) {
if (branchInfo == null) {
branchInfo = getBranchInfo();
}
Repository repository = git.getRepository();
RevWalk walk = new RevWalk(repository);
ObjectId localCommit = null;
ObjectId remoteCommit = null;
ObjectId baseCommit = null;
try {
remoteCommit = repository.resolve("origin/" + branchInfo.getBranchName() + "^{commit}");
localCommit = repository.resolve("HEAD^{commit}");
if (remoteCommit != null && localCommit != null) {
RevCommit base = getCommonAncestor(walk, walk.parseCommit(localCommit), walk.parseCommit(remoteCommit));
if (base != null) {
baseCommit = base.toObjectId();
}
}
} catch (IOException e) {
if (logger.isDebugEnabled()) {
logger.debug(e, e);
}
}
walk.close();
return baseCommit;
}