Java 类org.eclipse.jgit.api.DiffCommand 实例源码

项目:sonar-scm-git    文件:GitScmProviderTest.java   
@Test
public void branchChangedFiles_should_return_null_on_git_api_errors() throws GitAPIException {
  DiffCommand diffCommand = mock(DiffCommand.class);
  when(diffCommand.setShowNameAndStatusOnly(anyBoolean())).thenReturn(diffCommand);
  when(diffCommand.setOldTree(any())).thenReturn(diffCommand);
  when(diffCommand.call()).thenThrow(mock(GitAPIException.class));

  Git git = mock(Git.class);
  when(git.diff()).thenReturn(diffCommand);

  GitScmProvider provider = new GitScmProvider(mockCommand()) {
    @Override
    Git newGit(Repository repo) {
      return git;
    }
  };
  assertThat(provider.branchChangedFiles("branch", worktree)).isNull();
}
项目:pdi-git-plugin    文件:UIGit.java   
private DiffCommand getDiffCommand( String oldCommitId, String newCommitId ) throws Exception {
  return git.diff()
    .setOldTree( getTreeIterator( oldCommitId ) )
    .setNewTree( getTreeIterator( newCommitId ) );
}
项目:salesforce-migration-assistant    文件:SMAGit.java   
/**
 * Returns the diff between two commits.
 *
 * @return List that contains DiffEntry objects of the changes made between the previous and current commits.
 * @throws Exception
 */
private void getDiffs() throws Exception
{
    OutputStream out = new ByteArrayOutputStream();
    CanonicalTreeParser oldTree = getTree(prevCommit);
    CanonicalTreeParser newTree = getTree(curCommit);
    DiffCommand diff = git.diff().setOutputStream(out).setOldTree(oldTree).setNewTree(newTree);
    diffs = diff.call();
}