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
parent
7a1d3964a6
commit
1ece383d3b
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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/",
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue