use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testIgnoreFile.
@Test
public void testIgnoreFile() throws Exception {
IFile aFile = project.createFile("aFile.txt", new byte[0]);
IgnoreOperation operation = executeIgnore(aFile.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
assertEquals("/aFile.txt\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testWithNestedProjects.
@Test
public void testWithNestedProjects() throws Exception {
TestProject nested = new TestProject(true, "Project-1/Project-2");
try {
// Use Project-1 to create folder, Project-2 to get file to try to
// confuse any caches in workspace root (location -> IResource).
project.createFolder("Project-2/please");
IFile ignoreme = nested.createFile("please/ignoreme", new byte[0]);
IgnoreOperation operation = executeIgnore(ignoreme.getLocation());
String content = nested.getFileContent("please/.gitignore");
assertEquals("/ignoreme\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
} finally {
nested.dispose();
}
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method executeIgnore.
private IgnoreOperation executeIgnore(IPath... paths) throws Exception {
final IgnoreOperation operation = new IgnoreOperation(Arrays.asList(paths));
Job job = new Job("Ignoring resources for test") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
operation.execute(monitor);
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
};
job.setRule(operation.getSchedulingRule());
job.schedule();
job.join();
if (!job.getResult().isOK())
fail("Ignore job failed: " + job.getResult());
return operation;
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationTest method testSchedulingRule.
@Test
public void testSchedulingRule() throws Exception {
IFolder binFolder = project.getProject().getFolder("bin");
IgnoreOperation operation = executeIgnore(binFolder.getLocation());
assertNotNull(operation.getSchedulingRule());
}
use of org.eclipse.egit.core.op.IgnoreOperation in project egit by eclipse.
the class IgnoreOperationUI method run.
/**
* Run the operation.
*/
public void run() {
if (paths.size() > WARNING_THRESHOLD) {
Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
if (!MessageDialog.openQuestion(shell, MessageFormat.format(UIText.IgnoreActionHandler_manyFilesToBeIgnoredTitle, Integer.toString(paths.size())), UIText.IgnoreActionHandler_manyFilesToBeIgnoredQuestion)) {
return;
}
}
final IgnoreOperation operation = new IgnoreOperation(paths);
String jobname = UIText.IgnoreActionHandler_addToGitignore;
Job job = new WorkspaceJob(jobname) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
try {
operation.execute(monitor);
} catch (CoreException e) {
return Activator.createErrorStatus(e.getStatus().getMessage(), e);
}
if (operation.isGitignoreOutsideWSChanged()) {
refresh();
}
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
return Status.OK_STATUS;
} finally {
monitor.done();
}
}
};
job.setUser(true);
job.setRule(operation.getSchedulingRule());
job.schedule();
}
Aggregations