use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreNoTrailingNewline.
@Test
public void testIgnoreNoTrailingNewline() throws Exception {
String existing = "/nonewline";
IFile ignore = project.getProject().getFile(Constants.GITIGNORE_FILENAME);
assertFalse(ignore.exists());
ignore.create(new ByteArrayInputStream(existing.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor());
IFolder binFolder = project.getProject().getFolder("bin");
IgnoreOperation operation = executeIgnore(binFolder.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
assertEquals(existing + "\n/bin/\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreFileCancel.
@Test
public void testIgnoreFileCancel() throws Exception {
IFolder binFolder = project.getProject().getFolder("bin");
IgnoreOperation operation = new IgnoreOperation(Arrays.asList(binFolder.getLocation()));
NullProgressMonitor monitor = new NullProgressMonitor();
monitor.setCanceled(true);
operation.execute(monitor);
assertFalse(project.getProject().getFile(Constants.GITIGNORE_FILENAME).exists());
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreProject.
@Test
public void testIgnoreProject() throws Exception {
IgnoreOperation operation = executeIgnore(project.getProject().getLocation());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
File rootFile = root.getRawLocation().toFile();
File ignoreFile = new File(rootFile, Constants.GITIGNORE_FILENAME);
String content = testUtils.slurpAndClose(ignoreFile.toURI().toURL().openStream());
assertEquals("/.metadata/\n/" + project.getProject().getName() + "/\n", content);
assertTrue(operation.isGitignoreOutsideWSChanged());
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreWithResource.
@Test
public void testIgnoreWithResource() throws Exception {
IFolder binFolder = project.getProject().getFolder("bin");
Collection<IPath> c = Collections.singletonList(binFolder.getLocation());
IgnoreOperation operation = new IgnoreOperation(c);
operation.execute(new NullProgressMonitor());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
assertEquals("/bin/\n", content);
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreFolder.
@Test
public void testIgnoreFolder() throws Exception {
IFolder binFolder = project.getProject().getFolder("bin");
IgnoreOperation operation = executeIgnore(binFolder.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
assertEquals("/bin/\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
}
Aggregations