fixup! Omit extracting subfolder from a workspace URL
parent
e35377a56b
commit
bcc84f3a11
|
|
@ -104,15 +104,15 @@ public class GithubURLParser {
|
|||
}
|
||||
|
||||
public boolean isValid(@NotNull String url) {
|
||||
return githubPattern.matcher(url).matches();
|
||||
return githubPattern.matcher(trimEnd(url, '/')).matches();
|
||||
}
|
||||
|
||||
public GithubUrl parseWithoutAuthentication(String url) throws ApiException {
|
||||
return parse(url, false);
|
||||
return parse(trimEnd(url, '/'), false);
|
||||
}
|
||||
|
||||
public GithubUrl parse(String url) throws ApiException {
|
||||
return parse(url, true);
|
||||
return parse(trimEnd(url, '/'), true);
|
||||
}
|
||||
|
||||
private GithubUrl parse(String url, boolean authenticationRequired) throws ApiException {
|
||||
|
|
|
|||
|
|
@ -93,7 +93,8 @@ public class GitlabUrlParser {
|
|||
}
|
||||
|
||||
public boolean isValid(@NotNull String url) {
|
||||
return gitlabUrlPatterns.stream().anyMatch(pattern -> pattern.matcher(url).matches())
|
||||
return gitlabUrlPatterns.stream()
|
||||
.anyMatch(pattern -> pattern.matcher(trimEnd(url, '/')).matches())
|
||||
// If the Gitlab URL is not configured, try to find it in a manually added user namespace
|
||||
// token.
|
||||
|| isUserTokenPresent(url)
|
||||
|
|
@ -144,15 +145,15 @@ public class GitlabUrlParser {
|
|||
* {@link GitlabUrl} objects.
|
||||
*/
|
||||
public GitlabUrl parse(String url) {
|
||||
|
||||
String trimmedUrl = trimEnd(url, '/');
|
||||
Optional<Matcher> matcherOptional =
|
||||
gitlabUrlPatterns.stream()
|
||||
.map(pattern -> pattern.matcher(url))
|
||||
.map(pattern -> pattern.matcher(trimmedUrl))
|
||||
.filter(Matcher::matches)
|
||||
.findFirst()
|
||||
.or(() -> getPatternMatcherByUrl(url));
|
||||
.or(() -> getPatternMatcherByUrl(trimmedUrl));
|
||||
if (matcherOptional.isPresent()) {
|
||||
return parse(matcherOptional.get()).withUrl(url);
|
||||
return parse(matcherOptional.get()).withUrl(trimmedUrl);
|
||||
} else {
|
||||
throw new UnsupportedOperationException(
|
||||
"The gitlab integration is not configured properly and cannot be used at this moment."
|
||||
|
|
|
|||
|
|
@ -132,14 +132,9 @@ public class GitlabUrlParserTest {
|
|||
{"https://gitlab1.com/user/project/", "project", "user/project", null},
|
||||
{"https://gitlab1.com/user/project/repo/", "repo", "user/project/repo", null},
|
||||
{"https://gitlab1.com/user/project/-/tree/master/", "project", "user/project", "master"},
|
||||
{"https://gitlab1.com/user/project/repo/-/tree/foo", "repo", "user/project/repo", "foo"},
|
||||
{
|
||||
"https://gitlab1.com/user/project/repo/-/tree/foo/subfolder",
|
||||
"repo",
|
||||
"user/project/repo",
|
||||
"foo"
|
||||
},
|
||||
{
|
||||
"https://gitlab1.com/user/project/group1/group2/repo/-/tree/foo/subfolder",
|
||||
"https://gitlab1.com/user/project/group1/group2/repo/-/tree/foo/",
|
||||
"repo",
|
||||
"user/project/group1/group2/repo",
|
||||
"foo"
|
||||
|
|
|
|||
|
|
@ -85,10 +85,6 @@ public class GitlabUrlTest {
|
|||
"https://gitlab.net/eclipse/fooproj/che/-/tree/foobranch/",
|
||||
"https://gitlab.net/api/v4/projects/eclipse%%2Ffooproj%%2Fche/repository/files/%s/raw?ref=foobranch"
|
||||
},
|
||||
{
|
||||
"https://gitlab.net/eclipse/fooproj/che/-/tree/foobranch/subfolder",
|
||||
"https://gitlab.net/api/v4/projects/eclipse%%2Ffooproj%%2Fche/repository/files/%s/raw?ref=foobranch"
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue