当前位置: 首页>>代码示例>>Java>>正文


Java DiffEntry类代码示例

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


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

示例1: fillLastModifiedCommits

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
private void fillLastModifiedCommits(ObjectId start, String basePath) throws IOException, GitAPIException {
    Map<String, ObjectId> objects = lastModifiedCommits.get(start);
    if (objects == null) {
        objects = new TreeMap<>();
    }
    DiffFormatter diffFmt = new DiffFormatter(NullOutputStream.INSTANCE);
    diffFmt.setRepository(getGitRepository());
    LogCommand log = new Git(getGitRepository()).log();
    if (!basePath.isEmpty()) {
        log.addPath(basePath);
    }
    for(RevCommit c: log.call()) {
        final RevTree a = c.getParentCount() > 0 ? c.getParent(0).getTree() : null;
        final RevTree b = c.getTree();

        for(DiffEntry diff: diffFmt.scan(a, b)) {
            objects.put(diff.getNewPath(), c.getId());
        }
    }
    lastModifiedCommits.put(start, objects);
}
 
开发者ID:naver,项目名称:svngit,代码行数:22,代码来源:GitFS.java

示例2: getPaths

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
private List<DiffEntry> getPaths(Repository repository, RevCommit rev)
		throws MissingObjectException, IncorrectObjectTypeException,
		IOException {
	RevCommit parent = null;
	List<DiffEntry> diffs = null;
	RevWalk rw = new RevWalk(repository);
	DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE);

	df.setRepository(repository);
	df.setDiffComparator(RawTextComparator.DEFAULT);
	df.setDetectRenames(true);

	if (rev.getParentCount() > 0 && rev.getParent(0) != null) {
		parent = rw.parseCommit(rev.getParent(0).getId());
		diffs = df.scan(parent.getTree(), rev.getTree());
	} else {
		diffs = df.scan(new EmptyTreeIterator(), new CanonicalTreeParser(
				null, rw.getObjectReader(), rev.getTree()));
	}

	return diffs;
}
 
开发者ID:aserg-ufmg,项目名称:ModularityCheck,代码行数:23,代码来源:GITLogHandler.java

示例3: blockingPreviewDiff

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
private Map<String, Change<?>> blockingPreviewDiff(Revision baseRevision, Iterable<Change<?>> changes) {
    requireNonNull(baseRevision, "baseRevision");
    requireNonNull(changes, "changes");
    baseRevision = blockingNormalize(baseRevision);

    try (ObjectReader reader = jGitRepository.newObjectReader();
         RevWalk revWalk = new RevWalk(reader);
         DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE)) {

        final ObjectId baseTreeId = toTreeId(revWalk, baseRevision);
        final DirCache dirCache = DirCache.newInCore();
        final int numEdits = applyChanges(baseRevision, baseTreeId, dirCache, changes);
        if (numEdits == 0) {
            return Collections.emptyMap();
        }

        CanonicalTreeParser p = new CanonicalTreeParser();
        p.reset(reader, baseTreeId);
        diffFormatter.setRepository(jGitRepository);
        List<DiffEntry> result = diffFormatter.scan(p, new DirCacheIterator(dirCache));
        return toChangeMap(result);
    } catch (IOException e) {
        throw new StorageException("failed to perform a dry-run diff", e);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:26,代码来源:GitRepository.java

示例4: hasMatchingChanges

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
private boolean hasMatchingChanges(Revision from, Revision to, PathPatternFilter filter) {
    try (RevWalk revWalk = new RevWalk(jGitRepository)) {
        final List<DiffEntry> diff =
                compareTrees(toTreeId(revWalk, from), toTreeId(revWalk, to), TreeFilter.ALL);
        for (DiffEntry e : diff) {
            final String path;
            switch (e.getChangeType()) {
            case ADD:
                path = e.getNewPath();
                break;
            case MODIFY:
            case DELETE:
                path = e.getOldPath();
                break;
            default:
                throw new Error();
            }

            if (filter.matches(path)) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:line,项目名称:centraldogma,代码行数:27,代码来源:GitRepository.java

示例5: notifyWatchers

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
private void notifyWatchers(Revision newRevision, ObjectId prevTreeId, ObjectId nextTreeId) {
    final List<DiffEntry> diff = compareTrees(prevTreeId, nextTreeId, TreeFilter.ALL);
    for (DiffEntry e: diff) {
        switch (e.getChangeType()) {
        case ADD:
            commitWatchers.notify(newRevision, e.getNewPath());
            break;
        case MODIFY:
        case DELETE:
            commitWatchers.notify(newRevision, e.getOldPath());
            break;
        default:
            throw new Error();
        }
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:GitRepository.java

示例6: main

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {

        Repository repo = Commands.getRepo(Consts.META_REPO_PATH);

        // Get the id of the tree associated to the two commits
        ObjectId head = repo.resolve("HEAD^{tree}");
        ObjectId previousHead = repo.resolve("HEAD~^{tree}");

        List<DiffEntry> list = listDiffs(repo, previousHead, head);
        if(list != null){            
            // Simply display the diff between the two commits
            list.forEach((diff) -> {
                System.out.println(diff);
            });
        }
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:17,代码来源:Diffs.java

示例7: getStagedFiles

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
@Override
public List<UIFile> getStagedFiles( String oldCommitId, String newCommitId ) {
  List<UIFile> files = new ArrayList<UIFile>();
  try {
    List<DiffEntry> diffs = getDiffCommand( oldCommitId, newCommitId )
      .setShowNameAndStatusOnly( true )
      .call();
    RenameDetector rd = new RenameDetector( git.getRepository() );
    rd.addAll( diffs );
    diffs = rd.compute();
    diffs.forEach( diff -> {
      files.add( new UIFile( diff.getChangeType() == ChangeType.DELETE ? diff.getOldPath() : diff.getNewPath(),
        diff.getChangeType(), false ) );
    } );
  } catch ( Exception e ) {
    e.printStackTrace();
  }
  return files;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:20,代码来源:UIGit.java

示例8: hasDiff

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
public static boolean hasDiff(Git git, String base, String name, String ext) 
                                                throws WsSrvException {    
   checkFile(base, name, ext).getAbsolutePath();

   // Prepare path for git save
   String fp = getLocalPath(name);

   List<DiffEntry> diff;
   try {
       diff = git.diff().setPathFilter(PathFilter.create(fp)).call();
   } catch (GitAPIException e) {
     throw new WsSrvException(260, "Unable retrieve git diff", e);
   }

   return diff.size() > 0;
}
 
开发者ID:osbitools,项目名称:OsBiToolsWs,代码行数:17,代码来源:GitUtils.java

示例9: getScmItems

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
/**
 * Get list of files in given revision.
 *
 * @param revCommit rev commit instance
 * @param filePath  optional value to filter list of changed files
 * @return list of files in given revision
 * @throws IOException
 */
public ArrayList<ScmItem> getScmItems(RevCommit revCommit, String filePath) {
    try (RevWalk rw = new RevWalk(repository)) {
        ArrayList<ScmItem> rez = new ArrayList<>();
        if (revCommit != null) {
            final DiffFormatter df = getDiffFormatter(filePath);
            final List<DiffEntry> diffs;
            try {
                diffs = df.scan(
                        revCommit.getParentCount() > 0 ? rw.parseCommit(revCommit.getParent(0).getId()).getTree() : null,
                        revCommit.getTree());
                diffs.stream()
                        .map(this::adaptDiffEntry)
                        .collect(Collectors.toCollection(() -> rez));

            } catch (IOException e) {
                log.log(Level.SEVERE, "Cannot collect items from rev commit", e);
            }
        }
        rw.dispose();
        return rez;
    }
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:31,代码来源:GitRepositoryService.java

示例10: isInPath

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

示例11: initNonemptyNotebookDir

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
@Test
public void initNonemptyNotebookDir() throws IOException, GitAPIException {
  //given - .git does not exit
  File dotGit = new File(Joiner.on(File.separator).join(notebooksDir, ".git"));
  assertThat(dotGit.exists()).isEqualTo(false);

  //when
  notebookRepo = new GitNotebookRepo(conf);

  //then
  Git git = notebookRepo.getGit();
  assertThat(git).isNotNull();

  assertThat(dotGit.exists()).isEqualTo(true);
  assertThat(notebookRepo.list()).isNotEmpty();

  List<DiffEntry> diff = git.diff().call();
  assertThat(diff).isEmpty();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:20,代码来源:GitNotebookRepoTest.java

示例12: name

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
@Test public void name() throws IOException, GitAPIException {
    ObjectId head = repo.resolve("HEAD^{tree}");
    ObjectId oldHead = repo.resolve("HEAD^^{tree}");


    ObjectReader reader = repo.newObjectReader();

    CanonicalTreeParser prevParser = new CanonicalTreeParser();
    prevParser.reset(reader, oldHead);

    CanonicalTreeParser headParser = new CanonicalTreeParser();
    headParser.reset(reader, head);

    List<DiffEntry> diffs = new Git(repo).diff()
            .setNewTree(headParser)
            .setOldTree(prevParser)
            .call();

    for (DiffEntry entry : diffs)
        System.out.println(entry);
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:22,代码来源:JGitDiscoveryTest.java

示例13: getChanges

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
/**
 * Returns the files which have been changed between {@code firstCommit} and {@code secondCommit}.
 */
ChangeSet getChanges(final ObjectId firstCommit, final ObjectId secondCommit) throws GitAPIException, IOException {
    final List<DiffEntry> diff = calculateDiff(firstCommit, secondCommit);
    try {
        checkout(secondCommit.getName());

        final ChangeSet changes = new ChangeSet();

        getChangedFiles(diff).forEach(f -> changes.getChangedFiles().put(normalizePath(f.getName()), readFileContent(f)));

        getRemovedFilePaths(diff).map(this::normalizePath).forEach(changes.getRemovedFiles()::add);

        return changes;
    } finally {
        resetGit();
    }
}
 
开发者ID:sdaschner,项目名称:asciiblog,代码行数:20,代码来源:ChangeCalculator.java

示例14: branchChangedFiles

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
@Nullable
@Override
public Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir) {
  try (Repository repo = buildRepo(rootBaseDir)) {
    Ref targetRef = repo.exactRef("refs/heads/" + targetBranchName);
    if (targetRef == null) {
      LOG.warn("Could not find ref: {}", targetBranchName);
      return null;
    }

    try (Git git = newGit(repo)) {
      return git.diff().setShowNameAndStatusOnly(true).setOldTree(prepareTreeParser(repo, targetRef)).call().stream()
        .filter(diffEntry -> diffEntry.getChangeType() == DiffEntry.ChangeType.ADD || diffEntry.getChangeType() == DiffEntry.ChangeType.MODIFY)
        .map(diffEntry -> repo.getWorkTree().toPath().resolve(diffEntry.getNewPath()))
        .collect(Collectors.toSet());
    }
  } catch (IOException | GitAPIException e) {
    LOG.warn(e.getMessage(), e);
  }
  return null;
}
 
开发者ID:SonarSource,项目名称:sonar-scm-git,代码行数:22,代码来源:GitScmProvider.java

示例15: checkpoint

import org.eclipse.jgit.diff.DiffEntry; //导入依赖的package包/类
@Override
public Revision checkpoint(String pattern, String commitMessage, AuthenticationInfo subject) {
  Revision revision = Revision.EMPTY;
  try {
    List<DiffEntry> gitDiff = git.diff().call();
    if (!gitDiff.isEmpty()) {
      LOG.debug("Changes found for pattern '{}': {}", pattern, gitDiff);
      DirCache added = git.add().addFilepattern(pattern).call();
      LOG.debug("{} changes are about to be commited", added.getEntryCount());
      RevCommit commit = git.commit().setMessage(commitMessage).call();
      revision = new Revision(commit.getName(), commit.getShortMessage(), commit.getCommitTime());
    } else {
      LOG.debug("No changes found {}", pattern);
    }
  } catch (GitAPIException e) {
    LOG.error("Failed to add+commit {} to Git", pattern, e);
  }
  return revision;
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:20,代码来源:GitNotebookRepo.java


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