當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。