Search in sources :

Example 11 with GitConnection

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

the class DiffTest method testDiffNameOnlyCachedNoCommit.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDiffNameOnlyCachedNoCommit(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(null).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 12 with GitConnection

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

the class FetchTest method testWhenThereAreNoAnyRemotes.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class, expectedExceptions = GitException.class, expectedExceptionsMessageRegExp = "No remote repository specified.  " + "Please, specify either a URL or a remote name from which new revisions should be fetched in request.")
public void testWhenThereAreNoAnyRemotes(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    //when
    connection.fetch(FetchParams.create(null));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 13 with GitConnection

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

the class GetCommitersTest method testGetCommitters.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testGetCommitters(GitConnectionFactory connectionFactory) throws GitException, IOException {
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    //given
    addFile(connection, "newfile", "newfile content");
    connection.add(AddParams.create(singletonList(".")));
    connection.commit(CommitParams.create("test commit"));
    //when
    List<GitUser> committers = connection.getCommiters();
    //then
    assertEquals(committers.size(), 1);
    assertEquals(committers.get(0), getTestGitUser());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) GitUser(org.eclipse.che.api.git.shared.GitUser) Test(org.testng.annotations.Test)

Example 14 with GitConnection

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

the class GitTestUtil method connectToInitializedGitRepository.

public static GitConnection connectToInitializedGitRepository(GitConnectionFactory connectionFactory, File repository) throws GitException, IOException {
    GitConnection connection = getTestUserConnection(connectionFactory, repository);
    connection.init(false);
    return connection;
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection)

Example 15 with GitConnection

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

the class InitTest method testInit.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testInit(GitConnectionFactory connectionFactory) throws GitException, URISyntaxException, IOException {
    GitConnection connection = getTestUserConnection(connectionFactory, repository);
    //check git is not initialized
    assertFalse(new File(repository, ".git").exists());
    //when
    connection.init(false);
    //then
    assertTrue(new File(repository, ".git").exists());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) File(java.io.File) 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