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


Java FollowFilter類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:centic9,項目名稱:jgit-cookbook,代碼行數:19,代碼來源:DiffRenamedFile.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:63,代碼來源:LogCommand.java

示例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;
}
 
開發者ID:afrojer,項目名稱:gitiles,代碼行數:15,代碼來源:LogServlet.java


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