use of org.eclipse.egit.core.op.RemoveFromIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldUnstExistingFile.
@Test
public void shouldUnstExistingFile() throws Exception {
// given
IFile file1 = createFileInRepo("a.txt");
new AddToIndexOperation(asList(file1)).execute(null);
testRepo.commit("first commit");
Thread.sleep(1000);
file1.setContents(new ByteArrayInputStream("other text".getBytes(project.project.getDefaultCharset())), 0, null);
new AddToIndexOperation(asList(file1)).execute(null);
// when
new RemoveFromIndexOperation(asList(file1.getLocation())).execute(null);
// then
assertTrue(testRepo.removedFromIndex(file1.getLocation().toPortableString()));
}
use of org.eclipse.egit.core.op.RemoveFromIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldUnstageFilesFromMultipleRepositories.
@Test
public void shouldUnstageFilesFromMultipleRepositories() throws Exception {
// given
IFile fileRepo1 = testUtils.addFileToProject(project.getProject(), "1.txt", "content");
IFile fileRepo2 = testUtils.addFileToProject(project2.getProject(), "2.txt", "content");
new AddToIndexOperation(asList(fileRepo1)).execute(null);
new AddToIndexOperation(asList(fileRepo2)).execute(null);
// when
new RemoveFromIndexOperation(Arrays.asList(fileRepo1.getLocation(), fileRepo2.getLocation())).execute(null);
// then
assertTrue(testRepo.removedFromIndex(fileRepo1.getLocation().toPortableString()));
assertTrue(testRepo.removedFromIndex(fileRepo2.getLocation().toPortableString()));
}
use of org.eclipse.egit.core.op.RemoveFromIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldUnstageFilesInNestedFolder.
@Test
public void shouldUnstageFilesInNestedFolder() throws Exception {
// given
IFile file1 = createFileInRepo("sub/next/a.txt");
IFile file2 = createFileInRepo("sub/next/b.txt");
IFolder container = project.getProject().getFolder("sub");
List<IFolder> addResources = asList(project.getProject().getFolder("sub"));
new AddToIndexOperation(addResources).execute(null);
testRepo.commit("first commit");
Thread.sleep(1000);
file1.setContents(new ByteArrayInputStream("other text".getBytes(project.project.getDefaultCharset())), 0, null);
file2.setContents(new ByteArrayInputStream("other text".getBytes(project.project.getDefaultCharset())), 0, null);
new AddToIndexOperation(addResources).execute(null);
// when
new RemoveFromIndexOperation(asList(container.getLocation())).execute(null);
// then
assertTrue(testRepo.removedFromIndex(file1.getLocation().toPortableString()));
assertTrue(testRepo.removedFromIndex(file2.getLocation().toPortableString()));
}
Aggregations