TW-56994 Add special error message in case we use github.com with http
authorMikhail Khorkov <mikhail.khorkov@jetbrains.com>
Fri, 5 Oct 2018 09:55:04 +0000 (16:55 +0700)
committerMikhail Khorkov <mikhail.khorkov@jetbrains.com>
Fri, 5 Oct 2018 09:55:40 +0000 (16:55 +0700)
git-server/src/jetbrains/buildServer/buildTriggers/vcs/git/GitServerUtil.java

index 232c9bfea2a40f40ca3c0093d78aa54f447ed8d7..3da7127814e846103fa557bc98e931ce938b8141 100644 (file)
@@ -513,6 +513,10 @@ public class GitServerUtil {
       Throwable cause = e.getCause();
       if (cause instanceof JSchException && "channel is not opened.".equals(cause.getMessage())) {
         return runWithNewTransport(r, url, authSettings, transportFactory, tn -> tn.fetch(progress, refSpecs));
+      } if ("http".equals(url.getScheme()) && url.getHost().contains("github.com") &&
+            e.getMessage() != null && e.getMessage().contains("301")) {
+        /* github returns 301 status code in case we use http protocol */
+        throw new TransportException("Please use https protocol in VCS root instead of http.", e);
       } else {
         if (ignoreMissingRemoteRef) {
           String missingRef = getMissingRemoteRef(e);