use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class IndexDiffCacheTest method testAddingAFile.
@Test
public void testAddingAFile() throws Exception {
new ConnectProviderOperation(project.project, repository.getDirectory()).execute(null);
// create first commit containing a dummy file
testRepository.createInitialCommit("testBranchOperation\n\nfirst commit\n");
prepareCacheEntry();
waitForListenerCalled();
final String fileName = "aFile";
// This call should trigger an indexDiffChanged event (triggered via
// resource changed event)
project.createFile(fileName, "content".getBytes("UTF-8"));
IndexDiffData indexDiffData = waitForListenerCalled();
String path = project.project.getFile(fileName).getFullPath().toString().substring(1);
if (!indexDiffData.getUntracked().contains(path))
fail("IndexDiffData did not contain aFile as untracked");
// This call should trigger an indexDiffChanged event
try (Git git = new Git(repository)) {
git.add().addFilepattern(path).call();
}
IndexDiffData indexDiffData2 = waitForListenerCalled();
if (indexDiffData2.getUntracked().contains(path))
fail("IndexDiffData contains aFile as untracked");
if (!indexDiffData2.getAdded().contains(path))
fail("IndexDiffData does not contain aFile as added");
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ProjectUtilTest method testRefreshRepositoryResources.
@Test
public void testRefreshRepositoryResources() throws Exception {
TestProject subdirProject = new TestProject(true, "subdir/Project-2");
new ConnectProviderOperation(project.getProject(), repository.getRepository().getDirectory()).execute(null);
new ConnectProviderOperation(subdirProject.getProject(), repository.getRepository().getDirectory()).execute(null);
IFile file1 = createOutOfSyncFile(project, "refresh1");
ProjectUtil.refreshRepositoryResources(repository.getRepository(), Arrays.asList("Project-1/refresh1"), new NullProgressMonitor());
assertTrue(file1.isSynchronized(IResource.DEPTH_ZERO));
IFile file2 = createOutOfSyncFile(project, "refresh2");
ProjectUtil.refreshRepositoryResources(repository.getRepository(), Arrays.asList("Project-1"), new NullProgressMonitor());
assertTrue(file2.isSynchronized(IResource.DEPTH_ZERO));
IFile file3 = createOutOfSyncFile(project, "refresh3");
ProjectUtil.refreshRepositoryResources(repository.getRepository(), Arrays.asList(""), new NullProgressMonitor());
assertTrue(file3.isSynchronized(IResource.DEPTH_ZERO));
IFile file4 = createOutOfSyncFile(subdirProject, "refresh4");
ProjectUtil.refreshRepositoryResources(repository.getRepository(), Arrays.asList("subdir"), new NullProgressMonitor());
assertTrue(file4.isSynchronized(IResource.DEPTH_ZERO));
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ProjectUtilTest method testGetProjects.
@Test
public void testGetProjects() throws Exception {
ConnectProviderOperation operation = new ConnectProviderOperation(project.getProject(), gitDir);
operation.execute(null);
IProject[] projects = ProjectUtil.getProjects(repository.getRepository());
assertEquals(1, projects.length);
IProject p = projects[0];
assertEquals("Project-1", p.getDescription().getName());
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ResourceUtilTest method connect.
private void connect(IProject p) throws CoreException {
ConnectProviderOperation operation = new ConnectProviderOperation(p, gitDir);
operation.execute(null);
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class GitCreateProjectViaWizardWizard method importProjects.
private void importProjects(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
switch(mySelectionPage.getWizardSelection()) {
case GitSelectWizardPage.EXISTING_PROJECTS_WIZARD:
{
final Set<ProjectRecord> projectsToCreate = new HashSet<>();
final List<IWorkingSet> workingSets = new ArrayList<>();
// get the data from the page in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectsToCreate.addAll(myProjectsImportPage.getCheckedProjects());
IWorkingSet[] workingSetArray = myProjectsImportPage.getSelectedWorkingSets();
workingSets.addAll(Arrays.asList(workingSetArray));
myProjectsImportPage.saveWidgetValues();
}
});
ProjectUtils.createProjects(projectsToCreate, workingSets.toArray(new IWorkingSet[workingSets.size()]), monitor);
break;
}
case GitSelectWizardPage.NEW_WIZARD:
{
final List<IProject> previousProjects = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot().getProjects());
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow()).run();
}
});
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
IProject[] currentProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
SubMonitor progress = SubMonitor.convert(monitor, currentProjects.length);
for (IProject current : currentProjects) {
if (!previousProjects.contains(current)) {
ConnectProviderOperation cpo = new ConnectProviderOperation(current, myRepository.getDirectory());
cpo.execute(progress.newChild(1));
} else {
progress.worked(1);
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
case GitSelectWizardPage.GENERAL_WIZARD:
{
final String[] projectName = new String[1];
final boolean[] defaultLocation = new boolean[1];
// get the data from the page in the UI thread
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
projectName[0] = myCreateGeneralProjectPage.getProjectName();
defaultLocation[0] = myCreateGeneralProjectPage.isDefaultLocation();
}
});
try {
IWorkspaceRunnable wsr = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor actMonitor) throws CoreException {
final IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(projectName[0]);
if (!defaultLocation[0]) {
desc.setLocation(new Path(myGitDir));
}
SubMonitor progress = SubMonitor.convert(actMonitor, 4);
IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(desc.getName());
prj.create(desc, progress.newChild(1));
prj.open(progress.newChild(1));
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_ONE, progress.newChild(1));
File repoDir = myRepository.getDirectory();
ConnectProviderOperation cpo = new ConnectProviderOperation(prj, repoDir);
cpo.execute(progress.newChild(1));
}
};
ResourcesPlugin.getWorkspace().run(wsr, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
break;
}
}
}
Aggregations