Search in sources :

Example 96 with GitConnection

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

the class ConfigTest method testShouldWarnOnInvalidPropertySetting.

@Test(expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "error: key does not contain a section: " + INVALID_PROPERTY_NAME + "\n", dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testShouldWarnOnInvalidPropertySetting(GitConnectionFactory connectionFactory) throws Exception {
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    connection.getConfig().add(INVALID_PROPERTY_NAME, PROPERTY_VALUE);
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 97 with GitConnection

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

the class DiffTest method testDiffNameOnlyCached.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffNameOnlyCached(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    makeCommitInMaster(connection);
    //when
    connection.add(AddParams.create(singletonList("aaa")));
    List<String> diff = readDiff(DiffParams.create().withFileFilter(null).withType(DiffType.NAME_ONLY).withNoRenames(false).withRenameLimit(0).withCommitA("HEAD").withCached(true), connection);
    //then
    assertEquals(diff.size(), 1);
    assertTrue(diff.contains("aaa"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 98 with GitConnection

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

the class DiffTest method testDiffNameStatusWithCommits.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffNameStatusWithCommits(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    makeCommitInMaster(connection);
    //change README.txt
    connection.add(AddParams.create(AddRequest.DEFAULT_PATTERN));
    connection.rm(RmParams.create(singletonList("README.txt")));
    connection.commit(CommitParams.create("testDiffNameStatusWithCommits"));
    //when
    List<String> diff = readDiff(DiffParams.create().withFileFilter(null).withType(DiffType.NAME_STATUS).withRenameLimit(0).withCommitA("HEAD^").withCommitB("HEAD"), connection);
    //then
    assertEquals(diff.size(), 2);
    assertTrue(diff.contains("D\tREADME.txt"));
    assertTrue(diff.contains("A\taaa"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 99 with GitConnection

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

the class DiffTest method testDiffNameStatus.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffNameStatus(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    makeCommitInMaster(connection);
    //when
    List<String> diff = readDiff(DiffParams.create().withType(DiffType.NAME_STATUS).withRenameLimit(0), connection);
    //then
    assertEquals(diff.size(), 1);
    assertTrue(diff.contains("M\taaa"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 100 with GitConnection

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

the class DiffTest method testDiffNameOnlyWithCommits.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffNameOnlyWithCommits(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
    List<String> diff = readDiff(DiffParams.create().withFileFilter(null).withType(DiffType.NAME_ONLY).withNoRenames(false).withRenameLimit(0).withCommitA("HEAD^1").withCommitB("HEAD"), connection);
    //then
    assertEquals(diff.size(), 2);
    assertTrue(diff.contains("README.txt"));
    assertTrue(diff.contains("aaa"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Aggregations

GitConnection (org.eclipse.che.api.git.GitConnection)102 Test (org.testng.annotations.Test)100 File (java.io.File)19 GitTestUtil.addFile (org.eclipse.che.git.impl.GitTestUtil.addFile)16 Revision (org.eclipse.che.api.git.shared.Revision)9 ArrayList (java.util.ArrayList)6 CommitParams (org.eclipse.che.api.git.params.CommitParams)5 FileOutputStream (java.io.FileOutputStream)3 MergeResult (org.eclipse.che.api.git.shared.MergeResult)3 DiffPage (org.eclipse.che.api.git.DiffPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 DiffParams (org.eclipse.che.api.git.params.DiffParams)2 ShowFileContentResponse (org.eclipse.che.api.git.shared.ShowFileContentResponse)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)1 LineConsumerFactory (org.eclipse.che.api.core.util.LineConsumerFactory)1 PullParams (org.eclipse.che.api.git.params.PullParams)1 RemoteAddParams (org.eclipse.che.api.git.params.RemoteAddParams)1 RemoteUpdateParams (org.eclipse.che.api.git.params.RemoteUpdateParams)1