Search in sources :

Example 51 with GitConnection

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

the class StatusTest method testRemovedFromFilesSystem.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testRemovedFromFilesSystem(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "a", "a content");
    addFile(connection, "b", "b content");
    //add "a" and "b"
    connection.add(AddParams.create(ImmutableList.of("a", "b")));
    //commit "a" and "b"
    connection.commit(CommitParams.create("add 2 test files"));
    //delete "a"
    deleteFile(connection, "a");
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertTrue(status.getRemoved().isEmpty());
    assertTrue(status.getAdded().isEmpty());
    assertTrue(status.getChanged().isEmpty());
    assertTrue(status.getConflicting().isEmpty());
    assertEquals(status.getMissing(), ImmutableList.of("a"));
    assertTrue(status.getUntracked().isEmpty());
    assertTrue(status.getUntrackedFolders().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 52 with GitConnection

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

the class StatusTest method testConflicting.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testConflicting(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "a", "a content");
    addFile(connection, "b", "b content");
    //add "a" and "b"
    connection.add(AddParams.create(ImmutableList.of("a", "b")));
    //commit "a" and "b"
    connection.commit(CommitParams.create("add 2 test files"));
    //switch to other branch
    connection.checkout(CheckoutParams.create("new_branch").withCreateNew(true));
    //modify and commit "a"
    addFile(connection, "a", "new_branch a content");
    connection.commit(CommitParams.create("a changed in new_branch").withAll(true));
    //switch back to master
    connection.checkout(CheckoutParams.create("master"));
    //modify and commit "a"
    addFile(connection, "a", "master content");
    connection.commit(CommitParams.create("a changed in master").withAll(true));
    //merge with "new_branch" to get conflict
    connection.merge("new_branch");
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertEquals(status.getConflicting(), ImmutableList.of("a"));
    assertTrue(status.getModified().isEmpty());
    assertTrue(status.getAdded().isEmpty());
    assertTrue(status.getUntracked().isEmpty());
    assertTrue(status.getMissing().isEmpty());
    assertTrue(status.getRemoved().isEmpty());
    assertTrue(status.getUntrackedFolders().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 53 with GitConnection

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

the class StatusTest method testUntracked.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testUntracked(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "a", "a content");
    addFile(connection, "b", "b content");
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertEquals(status.getUntracked(), ImmutableList.of("a", "b"));
    assertTrue(status.getAdded().isEmpty());
    assertTrue(status.getChanged().isEmpty());
    assertTrue(status.getConflicting().isEmpty());
    assertTrue(status.getMissing().isEmpty());
    assertTrue(status.getRemoved().isEmpty());
    assertTrue(status.getUntrackedFolders().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 54 with GitConnection

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

the class StatusTest method testUntrackedFolder.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testUntrackedFolder(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection.getWorkingDir().toPath().resolve("new_directory"), "a", "content of a");
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertEquals(status.getUntrackedFolders(), ImmutableList.of("new_directory"));
    assertTrue(status.getAdded().isEmpty());
    assertTrue(status.getChanged().isEmpty());
    assertTrue(status.getConflicting().isEmpty());
    assertTrue(status.getMissing().isEmpty());
    assertTrue(status.getRemoved().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 55 with GitConnection

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

the class TagCreateTest method testCreateTag.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testCreateTag(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    int beforeTagCount = connection.tagList(null).size();
    //when
    connection.tagCreate(TagCreateParams.create("v1").withMessage("first version"));
    //then
    int afterTagCount = connection.tagList(null).size();
    assertEquals(afterTagCount, beforeTagCount + 1);
}
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