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());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class IsInsideWorkTreeTest method shouldReturnFalseOutsideRepositoryDirectory.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void shouldReturnFalseOutsideRepositoryDirectory(GitConnectionFactory connectionFactory) throws ServerException, IOException, UnauthorizedException, URISyntaxException {
// given
GitConnection externalDir = connectionFactory.getConnection(regularDir);
// when
boolean isInsideWorkingTree = externalDir.isInsideWorkTree();
// then
assertFalse(isInsideWorkingTree);
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class LogTest method testLogWithFileFilter.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLogWithFileFilter(GitConnectionFactory connectionFactory) throws GitException, IOException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "README.txt", "someChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Initial add"));
addFile(connection, "README.txt", "newChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Second commit"));
addFile(connection, "README.txt", "otherChanges");
connection.add(AddParams.create(ImmutableList.of("README.txt")));
connection.commit(CommitParams.create("Third commit"));
addFile(connection, "newFile.txt", "someChanges");
connection.add(AddParams.create(ImmutableList.of("newFile.txt")));
connection.commit(CommitParams.create("Add newFile.txt"));
//when
int readMeCommitCount = connection.log(LogParams.create().withFileFilter(Collections.singletonList("README.txt"))).getCommits().size();
int newFileCommitCount = connection.log(LogParams.create().withFileFilter(Collections.singletonList("newFile.txt"))).getCommits().size();
List<String> fileFilter = new ArrayList<>();
fileFilter.add("README.txt");
fileFilter.add("newFile.txt");
int allFilesCommitCount = connection.log(LogParams.create().withFileFilter(fileFilter)).getCommits().size();
//then
assertEquals(3, readMeCommitCount);
assertEquals(1, newFileCommitCount);
assertEquals(4, allFilesCommitCount);
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class PushTest method testPushWhenLocalRepositoryIsUpToDate.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testPushWhenLocalRepositoryIsUpToDate(GitConnectionFactory connectionFactory) throws IOException, ServerException, URISyntaxException, UnauthorizedException {
//given
GitConnection remoteConnection = connectToGitRepositoryWithContent(connectionFactory, repository);
GitConnection localConnection = connectionFactory.getConnection(remoteRepo.getAbsolutePath());
localConnection.clone(CloneParams.create(remoteConnection.getWorkingDir().getAbsolutePath()));
//when
PushResponse pushResponse = localConnection.push(PushParams.create("origin").withRefSpec(singletonList("refs/heads/master:refs/heads/master")).withTimeout(-1));
//then
assertEquals(pushResponse.getCommandOutput(), "Everything up-to-date");
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class PushTest 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.push(PushParams.create(null));
}
Aggregations