Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.core.test/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java44
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/ProjectReferenceImporter.java10
3 files changed, 55 insertions, 3 deletions
diff --git a/org.eclipse.egit.core.test/META-INF/MANIFEST.MF b/org.eclipse.egit.core.test/META-INF/MANIFEST.MF
index f92508bfa4..e9ac61116e 100644
--- a/org.eclipse.egit.core.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.core.test/META-INF/MANIFEST.MF
@@ -12,10 +12,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)",
org.hamcrest;bundle-version="[1.1.0,2.0.0)",
- org.junit;bundle-version="[4.3.0,5.0.0)",
- org.mockito;bundle-version="[1.8.0,1.9.0)"
+ org.junit;bundle-version="[4.3.0,5.0.0)"
Bundle-ActivationPolicy: lazy
Import-Package: org.mockito;version="[1.8.0,1.9.0)",
+ org.mockito.runners;version="[1.8.0,1.9.0)",
org.mockito.stubbing;version="[1.8.0,1.9.0)",
org.eclipse.egit.core;version="[3.0.0,3.1.0)",
org.eclipse.egit.core.op;version="[3.0.0,3.1.0)",
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
index abaae24144..5e86e3b639 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitProjectSetCapabilityTest.java
@@ -14,6 +14,8 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
@@ -260,6 +262,34 @@ public class GitProjectSetCapabilityTest {
root.getLocation().append("existingbutdifferent/repo/project"), imported.getLocation());
}
+ @Test
+ public void testImportFromRepoWithUrlOnlyDifferingInUserName()
+ throws Exception {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IPath reposPath = root.getLocation().append("repos");
+ pathsToClean.add(reposPath.toFile());
+
+ IPath repoPath = reposPath.append("repo");
+ IProject project = createProject(repoPath, "project");
+ project.delete(false, true, null);
+ String url = createUrl(repoPath, "ssh", "userName");
+ File repoDir = createRepository(repoPath, url, "master");
+
+ RepositoryUtil util = Activator.getDefault().getRepositoryUtil();
+ util.addConfiguredRepository(repoDir);
+
+ String reference = createProjectReference(repoPath, "ssh", /* no user */
+ null, "master", "project");
+
+ addToWorkspace(new String[] { reference });
+
+ IProject imported = root.getProject("project");
+ assertEquals(
+ "Expected imported project to be from already existing repository. User name must be ignored in URL.",
+ root.getLocation().append("repos/repo/project"),
+ imported.getLocation());
+ }
+
private IProject createProject(String name) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject p = root.getProject(name);
@@ -311,10 +341,24 @@ public class GitProjectSetCapabilityTest {
return "1.0," + createUrl(repoPath) + "," + branch + "," + projectPath;
}
+ private static String createProjectReference(IPath repoPath,
+ String protocol, String user, String branch, String projectPath)
+ throws Exception {
+ return "1.0," + createUrl(repoPath, protocol, user) + "," + branch
+ + "," + projectPath;
+ }
+
private static String createUrl(IPath repoPath) {
return repoPath.toFile().toURI().toString();
}
+ private static String createUrl(IPath repoPath, String protocol, String user)
+ throws URISyntaxException {
+ URI uri = new URI(protocol, user, "localhost", 42, repoPath
+ .setDevice(null).makeAbsolute().toString(), null, null);
+ return uri.toString();
+ }
+
private void addToWorkspace(String[] references) throws TeamException {
capability.addToWorkspace(references,
new ProjectSetSerializationContext(),
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/ProjectReferenceImporter.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/ProjectReferenceImporter.java
index bb15a729ff..fc15b290ab 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/ProjectReferenceImporter.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/ProjectReferenceImporter.java
@@ -232,7 +232,8 @@ public class ProjectReferenceImporter {
return false;
}
- private static boolean containsRemoteForUrl(Config config, URIish url) throws URISyntaxException {
+ private static boolean containsRemoteForUrl(Config config, URIish url)
+ throws URISyntaxException {
Set<String> remotes = config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
for (String remote : remotes) {
String remoteUrl = config.getString(
@@ -242,6 +243,13 @@ public class ProjectReferenceImporter {
URIish existingUrl = new URIish(remoteUrl);
if (existingUrl.equals(url))
return true;
+
+ // try URLs without user name, since often project sets contain
+ // anonymous URLs, and remote URL might be anonymous as well
+ URIish anonExistingUrl = existingUrl.setUser(null);
+ URIish anonUrl = url.setUser(null);
+ if (anonExistingUrl.equals(anonUrl))
+ return true;
}
return false;
}

Back to the top