use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class PullTest 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.pull(PullParams.create(null));
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class FetchTest method testFetchBranch.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testFetchBranch(GitConnectionFactory connectionFactory) throws ServerException, IOException, UnauthorizedException, URISyntaxException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
GitConnection fetchConnection = connectionFactory.getConnection(fetchTestRepo.getAbsolutePath());
addFile(connection, "README", "readme content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("fetch test"));
//clone default repo into fetchRepo
fetchConnection.clone(CloneParams.create(repository.getAbsolutePath()));
//add new File into defaultRepository
addFile(connection, "newfile1", "newfile1 content");
//add file to index and make commit
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("fetch test"));
String branchName = "branch";
connection.checkout(CheckoutParams.create(branchName).withCreateNew(true));
addFile(connection, "otherfile1", "otherfile1 content");
addFile(connection, "otherfile2", "otherfile2 content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("fetch branch test"));
//when
fetchConnection.fetch(FetchParams.create(repository.getAbsolutePath()));
//then
//make merge with FETCH_HEAD
fetchConnection.merge("FETCH_HEAD");
assertTrue(new File(fetchTestRepo, "otherfile1").exists());
assertTrue(new File(fetchTestRepo, "otherfile2").exists());
assertEquals(fetchConnection.log(LogParams.create()).getCommits().get(0).getMessage(), "fetch branch test");
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class FetchTest method testSimpleFetch.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testSimpleFetch(GitConnectionFactory connectionFactory) throws ServerException, IOException, UnauthorizedException, URISyntaxException {
//given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
GitConnection fetchConnection = connectionFactory.getConnection(fetchTestRepo.getAbsolutePath());
addFile(connection, "README", "readme content");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("fetch test"));
//clone default repo into fetchRepo
fetchConnection.clone(CloneParams.create(connection.getWorkingDir().getAbsolutePath()).withWorkingDir(fetchConnection.getWorkingDir().getAbsolutePath()));
//add new File into defaultRepository
addFile(connection, "newfile1", "newfile1 content");
//add file to index and make commit
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("fetch test"));
//when
fetchConnection.fetch(FetchParams.create(repository.getAbsolutePath()));
//then
//make merge with FETCH_HEAD
fetchConnection.merge("FETCH_HEAD");
assertTrue(new File(fetchTestRepo, "newfile1").exists());
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class GitTestUtil method connectToGitRepositoryWithContent.
public static GitConnection connectToGitRepositoryWithContent(GitConnectionFactory connectionFactory, File repository) throws GitException, IOException {
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
addFile(connection, "README.txt", CONTENT);
connection.add(AddParams.create(singletonList("README.txt")));
connection.commit(CommitParams.create("Initial commit"));
return connection;
}
use of org.eclipse.che.api.git.GitConnection in project che by eclipse.
the class IsInsideWorkTreeTest method shouldReturnTrueInsideWorkingTree.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void shouldReturnTrueInsideWorkingTree(GitConnectionFactory connectionFactory) throws ServerException, IOException, UnauthorizedException, URISyntaxException {
// given
GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
// add new dir into working tree
addFile(connection.getWorkingDir().toPath().resolve("new_directory"), "a", "content of a");
connection.add(AddParams.create(singletonList(".")));
connection.commit(CommitParams.create("test"));
// when
boolean isInsideWorkingTree = connection.isInsideWorkTree();
// then
assertTrue(isInsideWorkingTree);
}
Aggregations