Search in sources :

Example 1 with DiffPage

use of org.eclipse.che.api.git.DiffPage in project che by eclipse.

the class DiffTest method readDiff.

private List<String> readDiff(DiffParams params, GitConnection connection) throws GitException, IOException {
    DiffPage diffPage = connection.diff(params);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    diffPage.writeTo(out);
    BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));
    String line;
    List<String> diff = new ArrayList<>();
    while ((line = reader.readLine()) != null) diff.add(line);
    return diff;
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) DiffPage(org.eclipse.che.api.git.DiffPage) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with DiffPage

use of org.eclipse.che.api.git.DiffPage in project che by eclipse.

the class DiffTest method testDiffRawWithCommits.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffRawWithCommits(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    makeCommitInMaster(connection);
    connection.add(AddParams.create(singletonList("aaa")));
    connection.rm(RmParams.create(singletonList("README.txt")));
    connection.commit(CommitParams.create("testDiffNameStatusWithCommits"));
    //when
    DiffParams params = DiffParams.create().withFileFilter(null).withType(DiffType.RAW).withNoRenames(false).withRenameLimit(0).withCommitA("HEAD^1").withCommitB("HEAD");
    DiffPage diffPage = connection.diff(params);
    //then
    diffPage.writeTo(System.out);
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) DiffPage(org.eclipse.che.api.git.DiffPage) DiffParams(org.eclipse.che.api.git.params.DiffParams) Test(org.testng.annotations.Test)

Example 3 with DiffPage

use of org.eclipse.che.api.git.DiffPage in project che by eclipse.

the class DiffTest method testDiffRaw.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffRaw(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    makeCommitInMaster(connection);
    //when
    DiffParams params = DiffParams.create().withFileFilter(null).withType(DiffType.RAW).withNoRenames(false).withRenameLimit(0);
    DiffPage diffPage = connection.diff(params);
    //then
    diffPage.writeTo(System.out);
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) DiffPage(org.eclipse.che.api.git.DiffPage) DiffParams(org.eclipse.che.api.git.params.DiffParams) Test(org.testng.annotations.Test)

Aggregations

DiffPage (org.eclipse.che.api.git.DiffPage)3 GitConnection (org.eclipse.che.api.git.GitConnection)2 DiffParams (org.eclipse.che.api.git.params.DiffParams)2 Test (org.testng.annotations.Test)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1