Skip to content

Commit

Permalink
Apply permanetn ref query param to the GitLab raw file location req…
Browse files Browse the repository at this point in the history
…uest (#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.
  • Loading branch information
vinokurig authored Sep 5, 2023
1 parent da5174b commit 6edfa39
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,8 @@ public String rawFileLocation(String fileName) {
.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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void shouldExpandRelativePaths() throws Exception {
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"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public static Object[][] urlsProvider() {
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"
},
{
"[email protected]:eclipse/che.git",
Expand Down

0 comments on commit 6edfa39

Please sign in to comment.