Apply permanetn `ref` query param to the GitLab raw file location request (#545)

A user claims that he couldn't start a workspace form GitLab repository because of the raw file location request doesn't contain the ref query parameter. Rework the way of generating the GitLab raw file location function to permanently add the ref query param.
pull/553/head
Igor Vinokur 2023-09-05 12:51:27 +03:00 committed by GitHub
parent da5174bf17
commit 6edfa3910f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 7 deletions

View File

@ -178,11 +178,8 @@ public class GitlabUrl extends DefaultFactoryUrl {
.add("repository")
.add("files")
.add(encode(fileName, Charsets.UTF_8))
.add("raw")
.add("raw?ref=" + (isNullOrEmpty(branch) ? "HEAD" : branch))
.toString();
if (branch != null) {
resultUrl = resultUrl + "?ref=" + branch;
}
return resultUrl;
}

View File

@ -41,7 +41,7 @@ public class GitlabAuthorizingFileContentProviderTest {
verify(urlFetcher)
.fetch(
eq(
"https://gitlab.net/api/v4/projects/eclipse%2Fche/repository/files/devfile.yaml/raw"),
"https://gitlab.net/api/v4/projects/eclipse%2Fche/repository/files/devfile.yaml/raw?ref=HEAD"),
eq("Bearer my-token"));
}

View File

@ -80,11 +80,11 @@ public class GitlabUrlTest {
return new Object[][] {
{
"https://gitlab.net/eclipse/che.git",
"https://gitlab.net/api/v4/projects/eclipse%%2Fche/repository/files/%s/raw"
"https://gitlab.net/api/v4/projects/eclipse%%2Fche/repository/files/%s/raw?ref=HEAD"
},
{
"https://gitlab.net/eclipse/fooproj/che.git",
"https://gitlab.net/api/v4/projects/eclipse%%2Ffooproj%%2Fche/repository/files/%s/raw"
"https://gitlab.net/api/v4/projects/eclipse%%2Ffooproj%%2Fche/repository/files/%s/raw?ref=HEAD"
},
{
"git@gitlab.net:eclipse/che.git",