• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AndTreeFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jgit.treewalk.filter.AndTreeFilter的典型用法代码示例。如果您正苦于以下问题:Java AndTreeFilter类的具体用法?Java AndTreeFilter怎么用?Java AndTreeFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AndTreeFilter类属于org.eclipse.jgit.treewalk.filter包,在下文中一共展示了AndTreeFilter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: filterOutOtherModulesChanges

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
private void filterOutOtherModulesChanges(final String modulePath, final List<String> childModules,
		final RevWalk walk) {
	final boolean isRootModule = ".".equals(modulePath);
	final boolean isMultiModuleProject = !isRootModule || !childModules.isEmpty();
	final List<TreeFilter> treeFilters = new LinkedList<>();
	treeFilters.add(TreeFilter.ANY_DIFF);
	if (isMultiModuleProject) {
		if (!isRootModule) {
			// for sub-modules, look for changes only in the sub-module
			// path...
			treeFilters.add(PathFilter.create(modulePath));
		}

		// ... but ignore any sub-modules of the current sub-module, because
		// they can change independently of the current module
		for (final String childModule : childModules) {
			final String path = isRootModule ? childModule : modulePath + "/" + childModule;
			treeFilters.add(PathFilter.create(path).negate());
		}

	}
	final TreeFilter treeFilter = treeFilters.size() == 1 ? treeFilters.get(0) : AndTreeFilter.create(treeFilters);
	walk.setTreeFilter(treeFilter);
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:25,代码来源:GitRepository.java


示例2: filterOutOtherModulesChanges

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
private void filterOutOtherModulesChanges(String modulePath, List<String> childModules, RevWalk walk) {
    boolean isRootModule = ".".equals(modulePath);
    boolean isMultiModuleProject = !isRootModule || !childModules.isEmpty();
    List<TreeFilter> treeFilters = new ArrayList<TreeFilter>();
    treeFilters.add(TreeFilter.ANY_DIFF);
    if (isMultiModuleProject) {
        if (!isRootModule) {
            // for sub-modules, look for changes only in the sub-module path...
            treeFilters.add(PathFilter.create(modulePath));
        }

        // ... but ignore any sub-modules of the current sub-module, because they can change independently of the current module
        for (String childModule : childModules) {
            String path = isRootModule ? childModule : modulePath + "/" + childModule;
            treeFilters.add(PathFilter.create(path).negate());
        }

    }
    TreeFilter treeFilter = treeFilters.size() == 1 ? treeFilters.get(0) : AndTreeFilter.create(treeFilters);
    walk.setTreeFilter(treeFilter);
}
 
开发者ID:danielflower,项目名称:multi-module-maven-release-plugin,代码行数:22,代码来源:TreeWalkingDiffDetector.java


示例3: getRevisaoMaisRecenteDoBranch

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
public Optional<Revisao> getRevisaoMaisRecenteDoBranch(String branchRef, Path caminhoRelativo) {

        RevCommit commit = comRepositorioAberto(uncheckedFunction(git -> {
            Repository repo = git.getRepository();
            RevWalk revWalk = new RevWalk(repo);

            revWalk.setTreeFilter(AndTreeFilter.create(PathFilter.create(caminhoRelativo.toString()), TreeFilter.ANY_DIFF));
            revWalk.markStart(revWalk.lookupCommit(repo.resolve(branchRef)));

            Iterator<RevCommit> revs = revWalk.iterator();
            if (revs.hasNext()) {
                return revs.next();
            }

            return null;
        }));

        if (commit == null) {
            return empty();
        }

        return of(new Revisao(commit));
    }
 
开发者ID:servicosgovbr,项目名称:editor-de-servicos,代码行数:24,代码来源:RepositorioGit.java


示例4: listFiles

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
private void listFiles() throws GitException {
    RevWalk revWalk = new RevWalk(repository);
    TreeWalk walk = new TreeWalk(repository);
    try {
        List<GitFileInfo> result;
        walk.reset();
        walk.setRecursive(true);
        RevCommit parentCommit = null;
        if (revCommit.getParentCount() > 0) {
            for (RevCommit commit : revCommit.getParents()) {
                revWalk.markStart(revWalk.lookupCommit(commit));
            }
            revWalk.setRevFilter(RevFilter.MERGE_BASE);
            Iterator<RevCommit> it = revWalk.iterator();
            if (it.hasNext()) {
                parentCommit = it.next();
            }
            if (parentCommit != null) {
                walk.addTree(parentCommit.getTree().getId());
            }
        }
        walk.addTree(revCommit.getTree().getId());
        walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilter.ANY_DIFF));
        if (parentCommit != null) {
            result = Utils.getDiffEntries(repository, walk, GitClassFactoryImpl.getInstance());
        } else {
            result = new ArrayList<GitFileInfo>();
            while (walk.next()) {
                result.add(new GitFileInfo(new File(repository.getWorkTree(), walk.getPathString()), walk.getPathString(), GitFileInfo.Status.ADDED, null, null));
            }
        }
        this.modifiedFiles = result.toArray(new GitFileInfo[result.size()]);
    } catch (IOException ex) {
        throw new GitException(ex);
    } finally {
        revWalk.release();
        walk.release();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:GitRevisionInfo.java


示例5: run

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    TreeWalk walk = new TreeWalk(repository);
    try {
        walk.reset();
        walk.setRecursive(true);
        walk.addTree(Utils.findCommit(repository, revisionFirst).getTree());
        walk.addTree(Utils.findCommit(repository, revisionSecond).getTree());
        Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots);
        if (pathFilters.isEmpty()) {
            walk.setFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, PathFilter.ANY_DIFF));
        } else {
            walk.setFilter(AndTreeFilter.create(new TreeFilter[] { 
                TreeFilter.ANY_DIFF,
                PathFilter.ANY_DIFF,
                PathFilterGroup.create(pathFilters)
            }));
        }
        List<GitRevisionInfo.GitFileInfo> infos = Utils.getDiffEntries(repository, walk, getClassFactory());
        for (GitRevisionInfo.GitFileInfo info : infos) {
            statuses.put(info.getFile(), info);
        }
    } catch (IOException ex) {
        throw new GitException(ex);
    } finally {
        walk.release();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CompareCommand.java


示例6: applyCriteria

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的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


示例7: getFileRevisions

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
@Nonnull
public static List<RevCommit> getFileRevisions(String path, AnyObjectId start, int skip, int limit, ObjectReader reader) throws IOException {
  path = normalizeNodePath(path);
  TreeFilter filter = AndTreeFilter.create(PathFilterGroup.createFromStrings(path), ANY_DIFF);
  return getHistory(start, skip, limit, filter, reader);
}
 
开发者ID:beijunyi,项目名称:ParallelGit,代码行数:7,代码来源:CommitUtils.java


示例8: getCommitDiffFiles

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
private List<DiffCommitFile> getCommitDiffFiles(RevCommit revCommit, String pattern)
    throws IOException {
  List<DiffEntry> diffs;
  TreeFilter filter = null;
  if (!isNullOrEmpty(pattern)) {
    filter =
        AndTreeFilter.create(
            PathFilterGroup.createFromStrings(Collections.singleton(pattern)),
            TreeFilter.ANY_DIFF);
  }
  List<DiffCommitFile> commitFilesList = new ArrayList<>();
  try (TreeWalk tw = new TreeWalk(repository)) {
    tw.setRecursive(true);
    // get the current commit parent in order to compare it with the current commit
    // and to get the list of DiffEntry.
    if (revCommit.getParentCount() > 0) {
      RevCommit parent = parseCommit(revCommit.getParent(0));
      tw.reset(parent.getTree(), revCommit.getTree());
      if (filter != null) {
        tw.setFilter(filter);
      } else {
        tw.setFilter(TreeFilter.ANY_DIFF);
      }
      diffs = DiffEntry.scan(tw);
    } else {
      // If the current commit has no parents (which means it is the initial commit),
      // then create an empty tree and compare it to the current commit to get the
      // list of DiffEntry.
      try (RevWalk rw = new RevWalk(repository);
          DiffFormatter diffFormat = new DiffFormatter(NullOutputStream.INSTANCE)) {
        diffFormat.setRepository(repository);
        if (filter != null) {
          diffFormat.setPathFilter(filter);
        }
        diffs =
            diffFormat.scan(
                new EmptyTreeIterator(),
                new CanonicalTreeParser(null, rw.getObjectReader(), revCommit.getTree()));
      }
    }
  }
  if (diffs != null) {
    commitFilesList.addAll(
        diffs
            .stream()
            .map(
                diff ->
                    newDto(DiffCommitFile.class)
                        .withOldPath(diff.getOldPath())
                        .withNewPath(diff.getNewPath())
                        .withChangeType(diff.getChangeType().name()))
            .collect(toList()));
  }
  return commitFilesList;
}
 
开发者ID:eclipse,项目名称:che,代码行数:56,代码来源:JGitConnection.java


示例9: writeTo

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
@Override
public final void writeTo(OutputStream out) throws IOException {
  DiffFormatter formatter = new DiffFormatter(new BufferedOutputStream(out));
  formatter.setRepository(repository);
  List<String> rawFileFilter = params.getFileFilter();
  TreeFilter pathFilter =
      (rawFileFilter != null && rawFileFilter.size() > 0)
          ? PathFilterGroup.createFromStrings(rawFileFilter)
          : TreeFilter.ALL;
  formatter.setPathFilter(AndTreeFilter.create(TreeFilter.ANY_DIFF, pathFilter));

  try {
    String commitA = params.getCommitA();
    String commitB = params.getCommitB();
    boolean cached = params.isCached();

    List<DiffEntry> diff;
    if (commitA == null && commitB == null && !cached) {
      diff = indexToWorkingTree(formatter);
    } else if (commitA != null && commitB == null && !cached) {
      diff = commitToWorkingTree(commitA, formatter);
    } else if (commitA == null && commitB != null) {
      diff = emptyToCommit(commitB, formatter);
    } else if (commitB == null) {
      diff = commitToIndex(commitA, formatter);
    } else {
      diff = commitToCommit(commitA, commitB, formatter);
    }

    DiffType type = params.getType();
    if (type == DiffType.NAME_ONLY) {
      writeNames(diff, out);
    } else if (type == DiffType.NAME_STATUS) {
      writeNamesAndStatus(diff, out);
    } else {
      writeRawDiff(diff, formatter);
    }
  } catch (GitException e) {
    LOG.error(e.getMessage());
  } finally {
    formatter.close();
    repository.close();
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:JGitDiffPage.java


示例10: determineVersions

import org.eclipse.jgit.treewalk.filter.AndTreeFilter; //导入依赖的package包/类
@Override
public TestVersionResult determineVersions(final String fetchRevision) throws StoreException.ReadException {
    try {
        final RevWalk walk = new RevWalk(git.getRepository());
        final ObjectId commitId = ObjectId.fromString(fetchRevision);
        final RevCommit headTree = walk.parseCommit(commitId);
        final RevTree tree = headTree.getTree();

        // now use a TreeWalk to iterate over all files in the Tree recursively
        // you can set Filters to narrow down the results if needed
        TreeWalk treeWalk = new TreeWalk(git.getRepository());
        treeWalk.addTree(tree);
        treeWalk.setFilter(AndTreeFilter
            .create(PathFilter.create(testDefinitionsDirectory), PathSuffixFilter.create("definition.json")));
        treeWalk.setRecursive(true);

        final List<TestVersionResult.Test> tests = Lists.newArrayList();
        while (treeWalk.next()) {
            final ObjectId id = treeWalk.getObjectId(0);
            // final RevTree revTree = walk.lookupTree(id);

            final String path = treeWalk.getPathString();
            final String[] pieces = path.split("/");
            final String testname = pieces[pieces.length - 2]; // tree / parent directory name

            // testname, blobid pair
            // note this is the blobid hash - not a commit hash
            // RevTree.id and RevBlob.id
            tests.add(new TestVersionResult.Test(testname, id.name()));
        }

        walk.dispose();
        return new TestVersionResult(
                tests,
                new Date(Long.valueOf(headTree.getCommitTime()) * 1000 /* convert seconds to milliseconds */),
                headTree.getAuthorIdent().toExternalString(),
                headTree.toObjectId().getName(),
                headTree.getFullMessage()
        );
    } catch (IOException e) {
        throw new StoreException.ReadException(e);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:44,代码来源:GitProctorCore.java



注:本文中的org.eclipse.jgit.treewalk.filter.AndTreeFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BadPropertyValueException类代码示例发布时间:2022-05-22
下一篇:
Java MessageListenerConcurrently类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap