TW-51763 better error when project is created for empty repository
authorDmitry Neverov <dmitry.neverov@gmail.com>
Wed, 4 Oct 2017 08:04:37 +0000 (10:04 +0200)
committerDmitry Neverov <dmitry.neverov@gmail.com>
Wed, 4 Oct 2017 08:04:37 +0000 (10:04 +0200)
git-server/src/jetbrains/buildServer/buildTriggers/vcs/git/GitUrlSupport.java
git-server/src/jetbrains/buildServer/buildTriggers/vcs/git/GitVcsSupport.java

index 86c8b8990d0659237405d31c479d56b2b675148c..400c5cf1c65c936b25ca1ad9efba319277812e78 100644 (file)
@@ -82,6 +82,8 @@ public class GitUrlSupport implements UrlSupport, PositionAware {
     } catch (VcsException e) {
       if (GitServerUtil.isAuthError(e))
         throw e;
+      if (GitVcsSupport.GIT_REPOSITORY_HAS_NO_BRANCHES.equals(e.getMessage()))
+        throw e;
       return null; // probably not git
     }
   }
index cdbff0bd691e5c1c9d4bb591319b59c743b34fcf..9ecab3fc83792ce3263264319cf0d07825c6b74c 100755 (executable)
@@ -57,6 +57,8 @@ public class GitVcsSupport extends ServerVcsSupport
 
   private static final Logger LOG = Logger.getInstance(GitVcsSupport.class.getName());
   private static final Logger PERFORMANCE_LOG = Logger.getInstance(GitVcsSupport.class.getName() + ".Performance");
+  static final String GIT_REPOSITORY_HAS_NO_BRANCHES = "Git repository has no branches";
+
   private ExtensionHolder myExtensionHolder;
   private volatile String myDisplayName = null;
   private final ServerPluginConfig myConfig;
@@ -162,7 +164,7 @@ public class GitVcsSupport extends ServerVcsSupport
       }
       if (branchRevisions.get(fullRef) == null && !gitRoot.isIgnoreMissingDefaultBranch()) {
         if (branchRevisions.isEmpty()) {
-          throw new VcsException("Git repository has no branches");
+          throw new VcsException(GIT_REPOSITORY_HAS_NO_BRANCHES);
         } else {
           throw new VcsException("Cannot find revision of the default branch '" + refInRoot + "' of vcs root '" + gitRoot.getName() + "'");
         }