use of org.eclipse.egit.core.op.AddToIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldUnTrackFile.
@Test
public void shouldUnTrackFile() throws Exception {
// given
IFile file1 = createFileInRepo("a.txt");
new AddToIndexOperation(asList(file1)).execute(null);
// when
new RemoveFromIndexOperation(Arrays.asList(file1.getLocation())).execute(null);
// then
assertTrue(testRepo.removedFromIndex(file1.getLocation().toPortableString()));
}
use of org.eclipse.egit.core.op.AddToIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldRemoveFromIndexOnInitialCommit.
@Test
public void shouldRemoveFromIndexOnInitialCommit() throws Exception {
testRepo.dispose();
FileUtils.delete(gitDir, FileUtils.RECURSIVE | FileUtils.RETRY);
testRepo = new TestRepository(gitDir);
testRepo.connect(project.getProject());
IFile file = testUtils.addFileToProject(project.getProject(), "file.txt", "content");
new AddToIndexOperation(asList(file)).execute(null);
assertTrue(testRepo.inIndex(file.getLocation().toString()));
new RemoveFromIndexOperation(Arrays.asList(file.getLocation())).execute(null);
assertFalse(testRepo.inIndex(file.getLocation().toString()));
assertTrue(file.getLocation().toFile().exists());
}
use of org.eclipse.egit.core.op.AddToIndexOperation in project egit by eclipse.
the class RemoveFromIndexOperationTest method shouldUnstageFilesInFolder.
@Test
public void shouldUnstageFilesInFolder() throws Exception {
// given
IFile file1 = createFileInRepo("sub/a.txt");
IFile file2 = createFileInRepo("sub/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()));
}
use of org.eclipse.egit.core.op.AddToIndexOperation in project egit by eclipse.
the class StashCreateOperationTest method testDefaultMessage.
@Test
public void testDefaultMessage() throws Exception {
IFile file = testUtils.addFileToProject(project.getProject(), "foo/a.txt", "some text");
new AddToIndexOperation(Arrays.asList(file)).execute(null);
StashCreateOperation stashCreateOperation = new StashCreateOperation(repository);
stashCreateOperation.execute(null);
try (RevWalk revWalk = new RevWalk(repository)) {
RevCommit commit = revWalk.parseCommit(repository.resolve("stash@{0}"));
assertTrue(commit.getFullMessage().length() > 0);
}
}
use of org.eclipse.egit.core.op.AddToIndexOperation in project egit by eclipse.
the class TrackUntrackOperationTest method testTrackProject.
@Test
public void testTrackProject() throws Exception {
final ArrayList<IContainer> containers = new ArrayList<IContainer>();
containers.add(project);
final ArrayList<IFile> files = new ArrayList<IFile>();
project.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource instanceof IFile)
files.add((IFile) resource);
return true;
}
});
IFile[] fileArr = files.toArray(new IFile[files.size()]);
assertTrackedState(fileArr, false);
AddToIndexOperation trop = new AddToIndexOperation(containers);
trop.execute(new NullProgressMonitor());
assertTrackedState(fileArr, true);
UntrackOperation utrop = new UntrackOperation(containers);
utrop.execute(new NullProgressMonitor());
assertTrackedState(fileArr, false);
}
Aggregations