in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/bitbucketCloud/BitbucketCloudRepositoryParser.java [52:88]
private Repository parseMercurialRepository(@NotNull String uri) {
if (uri.startsWith("ssh")) {
Matcher m = SSH_PATTERN.matcher(uri);
if (!m.matches()) {
LOG.warn("Cannot parse mercurial repository url " + uri);
return null;
}
String owner = m.group(1).toLowerCase();
String repo = m.group(2).toLowerCase();
return new Repository(uri, owner, repo);
}
URL url;
try {
url = new URL(uri);
} catch (MalformedURLException e) {
LOG.warn("Cannot parse mercurial repository url " + uri, e);
return null;
}
String path = url.getPath();
if (path == null) {
LOG.warn("Cannot parse mercurial repository url " + uri + ", path is empty");
return null;
}
if (path.startsWith("/"))
path = path.substring(1);
int idx = path.indexOf("/");
if (idx <= 0) {
LOG.warn("Cannot parse mercurial repository url " + uri);
return null;
}
String owner = path.substring(0, idx);
String repo = path.substring(idx + 1);
return new Repository(uri, owner, repo);
}