]> source.dussan.org Git - jgit.git/commitdiff
Provide a public entry method to determine whether a URI protocol is supported 03/803/1
authorAlex Blewitt <alex.blewitt@gmail.com>
Thu, 3 Jun 2010 23:38:50 +0000 (00:38 +0100)
committerAlex Blewitt <alex.blewitt@gmail.com>
Thu, 3 Jun 2010 23:38:50 +0000 (00:38 +0100)
org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java

index c0b2eedc006e639fe783a890314f83272964f81d..2fe3cb93265bf890e862b420d17cbb0dd2f14ce5 100644 (file)
@@ -318,6 +318,38 @@ public abstract class Transport {
                return cfg.getURIs().isEmpty() && cfg.getPushURIs().isEmpty();
        }
 
+       /**
+        * Determines whether the transport can handle the given URIish.
+        *
+        * @param remote
+        *            location of the remote repository.
+        * @return true if the protocol is supported.
+        */
+       public static boolean canHandleProtocol(final URIish remote) {
+               if (TransportGitSsh.canHandle(remote))
+                       return true;
+
+               else if (TransportHttp.canHandle(remote))
+                       return true;
+
+               else if (TransportSftp.canHandle(remote))
+                       return true;
+
+               else if (TransportGitAnon.canHandle(remote))
+                       return true;
+
+               else if (TransportAmazonS3.canHandle(remote))
+                       return true;
+
+               else if (TransportBundleFile.canHandle(remote))
+                       return true;
+
+               else if (TransportLocal.canHandle(remote))
+                       return true;
+
+               return false;
+       }
+
        /**
         * Open a new transport instance to connect two repositories.
         *