diff --git a/org.sonatype.m2e.egit/src/org/sonatype/m2e/egit/internal/EgitScmHandler.java b/org.sonatype.m2e.egit/src/org/sonatype/m2e/egit/internal/EgitScmHandler.java index b4a6b99..a98e2de 100644 --- a/org.sonatype.m2e.egit/src/org/sonatype/m2e/egit/internal/EgitScmHandler.java +++ b/org.sonatype.m2e.egit/src/org/sonatype/m2e/egit/internal/EgitScmHandler.java @@ -101,6 +101,28 @@ protected String normalizeUri(String uri) throws URISyntaxException { throw new URISyntaxException(uri, "Invalid git URI"); } + // Normalize uri like + // git@github.com:errai/errai.git/errai-common + // into + // git://github.com/errai/errai.git + // These 3 distinctions may happen independently in other cases. + //1. Replace @ with :// + if(uri.startsWith("git@")) { + uri = "git://" + uri.substring(4); + } + //2. Replace github.com: with github.com/ + String githubDotCom = "github.com"; + int pos = uri.indexOf(githubDotCom + ":"); + if(pos > 0) { + pos += githubDotCom.length(); + uri = uri.substring(0, pos) + "/" + uri.substring(pos + 1); + } + //3. Remove tail after .git + int dotGit = uri.indexOf(".git"); + if(dotGit >= 0 && uri.length() > dotGit + 4) { + uri = uri.substring(0, dotGit + 4); + } + URIish gitUri = new URIish(uri); if(gitUri.getScheme() == null) { if(gitUri.getHost() == null || "file".equals(gitUri.getHost())) {