Search in sources :

Example 6 with CommitParams

use of org.eclipse.che.api.git.params.CommitParams in project che by eclipse.

the class CommitTest method testChangeMessageOfLastCommit.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testChangeMessageOfLastCommit(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    addFile(connection, "NewFile.txt", CONTENT);
    connection.add(AddParams.create(ImmutableList.of("NewFile.txt")));
    connection.commit(CommitParams.create("First commit"));
    int beforeCommitsCount = connection.log(LogParams.create()).getCommits().size();
    //when
    CommitParams commitParams = CommitParams.create("Changed message").withAmend(true);
    connection.commit(commitParams);
    //then
    int afterCommitsCount = connection.log(LogParams.create()).getCommits().size();
    assertEquals(beforeCommitsCount, afterCommitsCount);
    assertEquals(connection.log(LogParams.create()).getCommits().get(0).getMessage(), commitParams.getMessage());
}
Also used : CommitParams(org.eclipse.che.api.git.params.CommitParams) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Aggregations

GitConnection (org.eclipse.che.api.git.GitConnection)6 CommitParams (org.eclipse.che.api.git.params.CommitParams)6 Test (org.testng.annotations.Test)5 Revision (org.eclipse.che.api.git.shared.Revision)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Files (com.google.common.io.Files)1 JSch (com.jcraft.jsch.JSch)1 JSchException (com.jcraft.jsch.JSchException)1 Session (com.jcraft.jsch.Session)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 System.lineSeparator (java.lang.System.lineSeparator)1 URISyntaxException (java.net.URISyntaxException)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1 OWNER_READ (java.nio.file.attribute.PosixFilePermission.OWNER_READ)1