Fixed accepting factory if GitHub repo URL contains trailing slash (#12867)

* Fix accepting factory if url contains trailing slash
* Improve error message if exception occurred during devfile processing

Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
7.20.x
Sergii Leshchenko 2019-03-12 16:48:52 +02:00 committed by GitHub
parent 7a1d3964a6
commit 1ece383d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -35,7 +35,7 @@ public class GithubURLParser {
*/
protected static final Pattern GITHUB_PATTERN =
Pattern.compile(
"^(?:http)(?:s)?(?:\\:\\/\\/)github.com/(?<repoUser>[^/]++)/(?<repoName>[^/]++)((?:/tree/(?<branchName>[^/]++)(?:/(?<subFolder>.*))?)|(/pull/(?<pullRequestId>[^/]++)))?$");
"^(?:http)(?:s)?(?:\\:\\/\\/)github.com/(?<repoUser>[^/]++)/(?<repoName>[^/]++)((/)|(?:/tree/(?<branchName>[^/]++)(?:/(?<subFolder>.*))?)|(/pull/(?<pullRequestId>[^/]++)))?$");
/** Regexp to find repository and branch name from PR link */
protected static final Pattern PR_DATA_PATTERN =

View File

@ -72,6 +72,7 @@ public class GithubURLParserTest {
public Object[][] urls() {
return new Object[][] {
{"https://github.com/eclipse/che"},
{"https://github.com/eclipse/che/"},
{"https://github.com/eclipse/che/tree/4.2.x"},
{"https://github.com/eclipse/che/tree/master/"},
{"https://github.com/eclipse/che/tree/master/dashboard/"},
@ -85,6 +86,7 @@ public class GithubURLParserTest {
public Object[][] expectedParsing() {
return new Object[][] {
{"https://github.com/eclipse/che", "eclipse", "che", "master", null},
{"https://github.com/eclipse/che/", "eclipse", "che", "master", null},
{"https://github.com/eclipse/che/tree/4.2.x", "eclipse", "che", "4.2.x", null},
{
"https://github.com/eclipse/che/tree/master/dashboard/",

View File

@ -106,7 +106,11 @@ public class URLFactoryBuilder {
.withV(CURRENT_VERSION)
.withWorkspace(DtoConverter.asDto(wsConfig)));
} catch (DevfileException e) {
throw new BadRequestException(e.getMessage());
throw new BadRequestException(
"Error occurred during creation a workspace from devfile located at `"
+ devfileLocation
+ "`. Cause: "
+ e.getMessage());
}
}