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


Java DiffFormatter.setPathFilter方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.diff.DiffFormatter.setPathFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java DiffFormatter.setPathFilter方法的具體用法?Java DiffFormatter.setPathFilter怎麽用?Java DiffFormatter.setPathFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.diff.DiffFormatter的用法示例。


在下文中一共展示了DiffFormatter.setPathFilter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isInPath

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private boolean isInPath(Repository repository, RevWalk walk, RevCommit commit) throws IOException {
    if (commit.getParentCount() == 0) {
        RevTree tree = commit.getTree();
        try (TreeWalk treeWalk = new TreeWalk(repository)) {
            treeWalk.addTree(tree);
            treeWalk.setRecursive(true);
            treeWalk.setFilter(pathFilter);
            return treeWalk.next();
        }
    } else {
        DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
        df.setRepository(repository);
        df.setPathFilter(pathFilter);
        RevCommit parent = walk.parseCommit(commit.getParent(0).getId());
        List<DiffEntry> diffs = df.scan(parent.getTree(), commit.getTree());
        return !diffs.isEmpty();
    }
}
 
開發者ID:jakubplichta,項目名稱:git-changelog-maven-plugin,代碼行數:19,代碼來源:RepositoryProcessor.java

示例2: getDiffString

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private String getDiffString() throws GitAPIException, IOException {
    ObjectId head = this.repo.resolve("HEAD");
    if(head == null) return "";

    // The following code is largely written by Tk421 on StackOverflow
    //      (http://stackoverflow.com/q/23486483)
    // Thanks! NOTE: comments are mine.
    ByteArrayOutputStream diffOutputStream = new ByteArrayOutputStream();
    DiffFormatter formatter = new DiffFormatter(diffOutputStream);
    formatter.setRepository(this.repo);
    formatter.setPathFilter(PathFilter.create(this.pathFilter.replaceAll("\\\\","/")));

    AbstractTreeIterator commitTreeIterator = prepareTreeParser(this.repo, head.getName());
    FileTreeIterator workTreeIterator = new FileTreeIterator(this.repo);

    // Scan gets difference between the two iterators.
    formatter.format(commitTreeIterator, workTreeIterator);

    return diffOutputStream.toString();
}
 
開發者ID:dmusican,項目名稱:Elegit,代碼行數:21,代碼來源:DiffHelper.java

示例3: formatHtmlDiff

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
private void formatHtmlDiff(OutputStream out,
    Repository repo, RevWalk walk,
    AbstractTreeIterator oldTree, AbstractTreeIterator newTree,
    String path)
    throws IOException {
  DiffFormatter diff = new HtmlDiffFormatter(renderer, out);
  try {
    if (!path.equals("")) {
      diff.setPathFilter(PathFilter.create(path));
    }
    diff.setRepository(repo);
    diff.setDetectRenames(true);
    diff.format(oldTree, newTree);
  } finally {
    diff.release();
  }
}
 
開發者ID:afrojer,項目名稱:gitiles,代碼行數:18,代碼來源:DiffServlet.java

示例4: getDiffFormatter

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
/**
 * Get diff formatter.
 *
 * @param filePath optional filter for diff
 * @return diff formater
 */
private DiffFormatter getDiffFormatter(String filePath) {
    final DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);
    df.setRepository(repository);
    df.setDiffComparator(RawTextComparator.DEFAULT);
    df.setDetectRenames(true);
    if (filePath != null) {
        df.setPathFilter(PathFilter.create(filePath));
    }
    return df;
}
 
開發者ID:iazarny,項目名稱:gitember,代碼行數:17,代碼來源:GitRepositoryService.java

示例5: run

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的package包/類
@Override
  protected void run() throws GitException {
      Repository repository = getRepository();
      DiffFormatter formatter = new DiffFormatter(out);
      formatter.setRepository(repository);
      ObjectReader or = null;
      String workTreePath = repository.getWorkTree().getAbsolutePath();
      try {
          Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots);
          if (!pathFilters.isEmpty()) {
              formatter.setPathFilter(PathFilterGroup.create(pathFilters));
          }
          if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) {
              // work-around for autocrlf
              formatter.setDiffComparator(new AutoCRLFComparator());
          }
          or = repository.newObjectReader();
          AbstractTreeIterator firstTree = getIterator(firstCommit, or);
          AbstractTreeIterator secondTree = getIterator(secondCommit, or);
          List<DiffEntry> diffEntries;
          if (secondTree instanceof WorkingTreeIterator) {
              // remote when fixed in JGit, see ExportDiffTest.testDiffRenameDetectionProblem
              formatter.setDetectRenames(false);
              diffEntries = formatter.scan(firstTree, secondTree);
              formatter.setDetectRenames(true);
              RenameDetector detector = formatter.getRenameDetector();
              detector.reset();
              detector.addAll(diffEntries);
diffEntries = detector.compute(new ContentSource.Pair(ContentSource.create(or), ContentSource.create((WorkingTreeIterator) secondTree)), NullProgressMonitor.INSTANCE);
          } else {
              formatter.setDetectRenames(true);
              diffEntries = formatter.scan(firstTree, secondTree);
          }
          for (DiffEntry ent : diffEntries) {
              if (monitor.isCanceled()) {
                  break;
              }
              listener.notifyFile(new File(workTreePath + File.separator + ent.getNewPath()), ent.getNewPath());
              formatter.format(ent);
          }
          formatter.flush();
      } catch (IOException ex) {
          throw new GitException(ex);
      } finally {
          if (or != null) {
              or.release();
          }
          formatter.release();
      }
  }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:51,代碼來源:ExportDiffCommand.java

示例6: writeTo

import org.eclipse.jgit.diff.DiffFormatter; //導入方法依賴的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


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