Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I gave a look at the JGit sources and there does not seem to be present a method to check for the validity of the remote repo. </p> <p>This is the <code>call</code> method of <code>CloneCommand</code>:</p> <pre><code>public Git call() throws JGitInternalException { try { URIish u = new URIish(uri); Repository repository = init(u); FetchResult result = fetch(repository, u); if (!noCheckout) checkout(repository, result); return new Git(repository); } catch (IOException ioe) { throw new JGitInternalException(ioe.getMessage(), ioe); } catch (InvalidRemoteException e) { throw new JGitInternalException(e.getMessage(), e); } catch (URISyntaxException e) { throw new JGitInternalException(e.getMessage(), e); } } </code></pre> <p>In order to get if the remote URL is invalid, when catching a <code>JGitInternalException</code> <code>e</code> you may get the actual cause with <code>e.getCause()</code> to look for <code>InvalidRemoteException</code> or even <code>URISyntaxException</code>, but as you pointed out you end up cloning if it is actually valid; the library does not allow you to interrupt the operation.</p> <p>Delving more deeply into the JGit code, the <code>TransportLocal</code> class has the <code>open(URIsh,Repository,String)</code> method you could have used to check if an <code>InvalidRemoteException</code> is thrown, but its constructor is not public. A do-it-yourself solution is required, alas. You could maybe start from the contents of the <code>TransportLocal.open</code> method I mentioned.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload