-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize uri like [email protected]:errai/errai.git/errai-common into git://github.com/errai/errai.git There are 3 independent operations: 1) set git:// instead git@ 2) set github.com/ instead github: 3) remove tail after .git
- Loading branch information
1 parent
af764de
commit 72dbf59
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,28 @@ protected String normalizeUri(String uri) throws URISyntaxException { | |
throw new URISyntaxException(uri, "Invalid git URI"); | ||
} | ||
|
||
// Normalize uri like | ||
// [email protected]: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())) { | ||
|