Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2020-06-26 09:49:11 +0000
committerLaurent Goubet2020-06-26 09:54:05 +0000
commit991266d5ed024d4d3c00e51a71a86c88ba45b4c9 (patch)
tree3e67fe06ca5f5053760a3207f5905a5e2422a1d9
parentf6a63eebf478bf5753818d9c1a0c58ad96d49a61 (diff)
downloadorg.eclipse.emf.compare-991266d5ed024d4d3c00e51a71a86c88ba45b4c9.tar.gz
org.eclipse.emf.compare-991266d5ed024d4d3c00e51a71a86c88ba45b4c9.tar.xz
org.eclipse.emf.compare-991266d5ed024d4d3c00e51a71a86c88ba45b4c9.zip
Fix GitTestSupport
Some tests may create their own projects that are not connected to a git repository Change-Id: I2a295a3ebfe92c7854d31fb6f8e3e78f281af4b2
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
index d2bfaf2d3..1a129ddf5 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
@@ -19,7 +19,9 @@ import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Comparator;
+import java.util.List;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -36,6 +38,8 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.eclipse.egit.core.op.DisconnectProviderOperation;
+import org.eclipse.egit.core.project.RepositoryFinder;
+import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
@@ -111,10 +115,18 @@ public class InternalGitTestSupport {
extractArchive(clazz, path, root);
importProjects(new File(location.toString()));
connectRepository(new File(location.toString()));
- projects = root.getProjects();
- for (IProject project : projects) {
- connect(project);
+ List<IProject> existingProjects = Arrays.asList(root.getProjects());
+ List<IProject> connectedProjects = new ArrayList<>();
+ for (IProject project : existingProjects) {
+ RepositoryFinder finder = new RepositoryFinder(project);
+ finder.setFindInChildren(false);
+ Collection<RepositoryMapping> repos = finder.find(new NullProgressMonitor());
+ if (!repos.isEmpty()) {
+ connect(project);
+ connectedProjects.add(project);
+ }
}
+ projects = connectedProjects.toArray(new IProject[connectedProjects.size()]);
}
/**
@@ -327,8 +339,13 @@ public class InternalGitTestSupport {
Activator.getDefault().getRepositoryCache().clear();
if (projects != null) {
- new DisconnectProviderOperation(Arrays.asList(projects)).execute(null);
+ List<IProject> disconnectMe = new ArrayList<>();
for (IProject iProject : projects) {
+ disconnectMe.add(iProject);
+ }
+ new DisconnectProviderOperation(disconnectMe).execute(null);
+
+ for (IProject iProject : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
iProject.delete(true, new NullProgressMonitor());
}
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,

Back to the top