diff --git a/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrl.java b/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrl.java index 057630821a..d00f86b3aa 100644 --- a/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrl.java +++ b/wsmaster/che-core-api-factory-gitlab/src/main/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrl.java @@ -11,10 +11,10 @@ */ package org.eclipse.che.api.factory.server.gitlab; +import static com.google.common.base.Strings.isNullOrEmpty; import static java.net.URLEncoder.encode; import com.google.common.base.Charsets; -import com.google.common.base.Strings; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -120,7 +120,7 @@ public class GitlabUrl extends DefaultFactoryUrl { } protected GitlabUrl withBranch(String branch) { - if (!Strings.isNullOrEmpty(branch)) { + if (!isNullOrEmpty(branch)) { this.branch = branch; } return this; @@ -165,11 +165,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; } diff --git a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabAuthorizingFileContentProviderTest.java b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabAuthorizingFileContentProviderTest.java index 0c784206ac..6f32acdd50 100644 --- a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabAuthorizingFileContentProviderTest.java +++ b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabAuthorizingFileContentProviderTest.java @@ -42,7 +42,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")); } diff --git a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlTest.java b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlTest.java index e03e5b49f1..05eb66954a 100644 --- a/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlTest.java +++ b/wsmaster/che-core-api-factory-gitlab/src/test/java/org/eclipse/che/api/factory/server/gitlab/GitlabUrlTest.java @@ -71,11 +71,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" }, { "https://gitlab.net/eclipse/fooproj/-/tree/master/",