use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class PushTest method testPushWhenLocalRepositoryIsNotSynchronisedWithRemote.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testPushWhenLocalRepositoryIsNotSynchronisedWithRemote(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()));
addFile(remoteConnection, "newfile", "content");
remoteConnection.add(AddParams.create(singletonList(".")));
remoteConnection.commit(CommitParams.create("Fake commit"));
//when
String errorMessage = "";
try {
localConnection.push(PushParams.create("origin").withTimeout(-1));
} catch (GitException exception) {
errorMessage = exception.getMessage();
}
//then
assertTrue(errorMessage.contains("master -> master"));
assertTrue(errorMessage.contains(remoteConnection.getWorkingDir().getAbsolutePath()));
}
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"));
}
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));
}
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());
}
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;
}
Aggregations