本文整理汇总了Java中org.eclipse.jgit.revwalk.RevWalk.close方法的典型用法代码示例。如果您正苦于以下问题:Java RevWalk.close方法的具体用法?Java RevWalk.close怎么用?Java RevWalk.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.revwalk.RevWalk
的用法示例。
在下文中一共展示了RevWalk.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLoaderFrom
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的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;
}
示例2: getBaseCommit
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的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;
}
示例3: updateWithRemoteFile
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的package包/类
public void updateWithRemoteFile(String filePath) {
try {
RevWalk walk = new RevWalk(git.getRepository());
walk.reset();
RevCommit commit = walk.parseCommit(git.getRepository().resolve("MERGE_HEAD"));
git.checkout().setStartPoint(commit).addPath(filePath).call();
walk.close();
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug(e, e);
}
}
}
示例4: getCommit
import org.eclipse.jgit.revwalk.RevWalk; //导入方法依赖的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;
}