本文整理汇总了Java中org.eclipse.jgit.revwalk.FollowFilter类的典型用法代码示例。如果您正苦于以下问题:Java FollowFilter类的具体用法?Java FollowFilter怎么用?Java FollowFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FollowFilter类属于org.eclipse.jgit.revwalk包,在下文中一共展示了FollowFilter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffFile
import org.eclipse.jgit.revwalk.FollowFilter; //导入依赖的package包/类
private static @NonNull DiffEntry diffFile(Repository repo, String oldCommit,
String newCommit, String path) throws IOException, GitAPIException {
Config config = new Config();
config.setBoolean("diff", null, "renames", true);
DiffConfig diffConfig = config.get(DiffConfig.KEY);
try (Git git = new Git(repo)) {
List<DiffEntry> diffList = git.diff().
setOldTree(prepareTreeParser(repo, oldCommit)).
setNewTree(prepareTreeParser(repo, newCommit)).
setPathFilter(FollowFilter.create(path, diffConfig)).
call();
if (diffList.size() == 0)
return null;
if (diffList.size() > 1)
throw new RuntimeException("invalid diff");
return diffList.get(0);
}
}
示例2: applyCriteria
import org.eclipse.jgit.revwalk.FollowFilter; //导入依赖的package包/类
private void applyCriteria (RevWalk walk, SearchCriteria criteria,
final RevFlag partOfResultFlag, DiffConfig diffConfig) {
File[] files = criteria.getFiles();
if (files.length > 0) {
Collection<PathFilter> pathFilters = Utils.getPathFilters(getRepository().getWorkTree(), files);
if (!pathFilters.isEmpty()) {
if (criteria.isFollow() && pathFilters.size() == 1) {
walk.setTreeFilter(FollowFilter.create(pathFilters.iterator().next().getPath(), diffConfig));
} else {
walk.setTreeFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilterGroup.create(pathFilters)));
}
}
}
RevFilter filter;
if (criteria.isIncludeMerges()) {
filter = RevFilter.ALL;
} else {
filter = RevFilter.NO_MERGES;
}
filter = AndRevFilter.create(filter, new CancelRevFilter(monitor));
filter = AndRevFilter.create(filter, new RevFilter() {
@Override
public boolean include (RevWalk walker, RevCommit cmit) {
return cmit.has(partOfResultFlag);
}
@Override
public RevFilter clone () {
return this;
}
@Override
public boolean requiresCommitBody () {
return false;
}
});
String username = criteria.getUsername();
if (username != null && !(username = username.trim()).isEmpty()) {
filter = AndRevFilter.create(filter, OrRevFilter.create(CommitterRevFilter.create(username), AuthorRevFilter.create(username)));
}
String message = criteria.getMessage();
if (message != null && !(message = message.trim()).isEmpty()) {
filter = AndRevFilter.create(filter, MessageRevFilter.create(message));
}
Date from = criteria.getFrom();
Date to = criteria.getTo();
if (from != null && to != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.between(from, to));
} else if (from != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.after(from));
} else if (to != null) {
filter = AndRevFilter.create(filter, CommitTimeRevFilter.before(to));
}
// this must be at the end, limit filter must apply as the last
if (criteria.getLimit() != -1) {
filter = AndRevFilter.create(filter, MaxCountRevFilter.create(criteria.getLimit()));
}
walk.setRevFilter(filter);
}
示例3: newWalk
import org.eclipse.jgit.revwalk.FollowFilter; //导入依赖的package包/类
private static RevWalk newWalk(Repository repo, GitilesView view)
throws MissingObjectException, IncorrectObjectTypeException, IOException {
RevWalk walk = new RevWalk(repo);
walk.markStart(walk.parseCommit(view.getRevision().getId()));
if (view.getOldRevision() != Revision.NULL) {
walk.markUninteresting(walk.parseCommit(view.getOldRevision().getId()));
}
if (!Strings.isNullOrEmpty(view.getPathPart())) {
walk.setTreeFilter(FollowFilter.create(
view.getPathPart(),
repo.getConfig().get(DiffConfig.KEY)));
}
return walk;
}