use of org.eclipse.egit.core.op.DisconnectProviderOperation in project jbosstools-openshift by jbosstools.
the class TestRepository method disconnect.
/**
* Disconnects provider from project
*
* @param project
* @throws CoreException
*/
public void disconnect(IProject project) throws CoreException {
Collection<IProject> projects = Collections.singleton(project.getProject());
DisconnectProviderOperation disconnect = new DisconnectProviderOperation(projects);
disconnect.execute(null);
}
use of org.eclipse.egit.core.op.DisconnectProviderOperation in project egit by eclipse.
the class GitBlobStorageTest method testGitFileHistorySingleProjectOk.
@Test
public void testGitFileHistorySingleProjectOk() throws Exception {
IProgressMonitor progress = new NullProgressMonitor();
TestProject singleRepoProject = new TestProject(true, "Project-2");
IProject proj = singleRepoProject.getProject();
File singleProjectGitDir = new File(proj.getLocation().toFile(), Constants.DOT_GIT);
if (singleProjectGitDir.exists())
FileUtils.delete(singleProjectGitDir, FileUtils.RECURSIVE | FileUtils.RETRY);
Repository singleProjectRepo = FileRepositoryBuilder.create(singleProjectGitDir);
singleProjectRepo.create();
// Repository must be mapped in order to test the GitFileHistory
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(singleProjectGitDir);
ConnectProviderOperation connectOp = new ConnectProviderOperation(proj, singleProjectGitDir);
connectOp.execute(progress);
try (Git git = new Git(singleProjectRepo)) {
IFile file = proj.getFile("file");
file.create(new ByteArrayInputStream("data".getBytes("UTF-8")), 0, progress);
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setAuthor("JUnit", "junit@jgit.org").setAll(true).setMessage("First commit").call();
GitFileHistoryProvider fhProvider = new GitFileHistoryProvider();
IFileHistory fh = fhProvider.getFileHistoryFor(singleRepoProject.getProject(), 0, null);
assertNotNull(fh);
assertEquals(fh.getFileRevisions().length, 1);
assertNotNull(fh.getFileRevision(commit.getId().getName()));
} finally {
DisconnectProviderOperation disconnectOp = new DisconnectProviderOperation(Collections.singletonList(proj));
disconnectOp.execute(progress);
Activator.getDefault().getRepositoryUtil().removeDir(singleProjectGitDir);
singleProjectRepo.close();
singleRepoProject.dispose();
}
}
use of org.eclipse.egit.core.op.DisconnectProviderOperation in project egit by eclipse.
the class SharingWizardTest method erase.
private void erase(String projectName, Set<File> dirs) throws CoreException, IOException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (project.exists()) {
RepositoryMapping repo = RepositoryMapping.getMapping(project);
if (repo != null) {
IPath gitDirAbsolutePath = repo.getGitDirAbsolutePath();
File canonicalFile = gitDirAbsolutePath.toFile().getCanonicalFile();
dirs.add(canonicalFile);
File workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalFile();
File gitDirParent = canonicalFile.getParentFile();
if (!(gitDirParent.toString() + File.separator).startsWith(workspacePath.toString() + File.separator))
if (!(gitDirParent.toString() + File.separator).startsWith(getTestDirectory().getAbsolutePath().toString() + File.separator))
fail("Attempting cleanup of directory neither in workspace nor test directory" + canonicalFile);
new DisconnectProviderOperation(Collections.singleton(project)).execute(null);
}
project.close(null);
project.delete(true, true, null);
}
}
use of org.eclipse.egit.core.op.DisconnectProviderOperation in project egit by eclipse.
the class TestRepository method disconnect.
/**
* Disconnects provider from project
*
* @param project
* @throws Exception
*/
public void disconnect(IProject project) throws Exception {
Collection<IProject> projects = Collections.singleton(project.getProject());
DisconnectProviderOperation disconnect = new DisconnectProviderOperation(projects);
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
disconnect.execute(null);
}
}, project, IWorkspace.AVOID_UPDATE, null);
TestUtils.waitForJobs(5000, null);
}
use of org.eclipse.egit.core.op.DisconnectProviderOperation in project egit by eclipse.
the class DisconnectActionHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IProject[] selectedProjects = getProjectsForSelectedResources();
List<IProject> projects = new ArrayList<>(selectedProjects.length);
for (IProject project : selectedProjects) {
if (project.isOpen() && ResourceUtil.isSharedWithGit(project)) {
projects.add(project);
}
}
if (projects.isEmpty()) {
return null;
}
JobUtil.scheduleUserJob(new DisconnectProviderOperation(projects), UIText.Disconnect_disconnect, JobFamilies.DISCONNECT, new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent actEvent) {
GitLightweightDecorator.refresh();
}
});
return null;
}
Aggregations