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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations