protected static boolean isSshUri(Object uri) { if(uri != null) { try { URIish urIish = new URIish(uri.toString()); String scheme = urIish.getScheme(); if(scheme == null && hasText(urIish.getHost()) && hasText(urIish.getUser())) { //JGit returns null if using SCP URI but user and host will be populated return true; } return scheme != null && !scheme.matches("^(http|https)$"); } catch (URISyntaxException e) { return false; } } return false; }
String commandFor(String exe) { String path = uri.getPath(); if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$ path = (uri.getPath().substring(1)); final StringBuilder cmd = new StringBuilder(); cmd.append(exe); cmd.append(' '); cmd.append(QuotedString.BOURNE.quote(path)); return cmd.toString(); }
NoRemoteRepositoryException cleanNotFound(NoRemoteRepositoryException nf, String why) { if (why == null || why.length() == 0) return nf; String path = uri.getPath(); if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$ path = uri.getPath().substring(1); final StringBuilder pfx = new StringBuilder(); pfx.append("fatal: "); //$NON-NLS-1$ pfx.append(QuotedString.BOURNE.quote(path)); pfx.append(": "); //$NON-NLS-1$ if (why.startsWith(pfx.toString())) why = why.substring(pfx.length()); return new NoRemoteRepositoryException(uri, why); }
@Override public Transport open(URIish uri) throws NotSupportedException, TransportException { if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$ File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$ return new TransportBundleFile(uri, path); } return TransportLocal.PROTO_LOCAL.open(uri); } };
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public Transport open(URIish uri, Repository local, String remoteName) throws NotSupportedException, TransportException { if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$ File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$ return new TransportBundleFile(local, uri, path); } // This is an ambiguous reference, it could be a bundle file // or it could be a Git repository. Allow TransportLocal to // resolve the path and figure out which type it is by testing // the target. // return TransportLocal.PROTO_LOCAL.open(uri, local, remoteName); }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getScheme() == null) { // scp-style URI "host:path" does not have scheme. return uri.getHost() != null && uri.getPath() != null && uri.getHost().length() != 0 && uri.getPath().length() != 0; } return super.canHandle(uri, local, remoteName); }
/** {@inheritDoc} */ @Override public int hashCode() { int hc = 0; if (getScheme() != null) hc = hc * 31 + getScheme().hashCode(); if (getUser() != null) hc = hc * 31 + getUser().hashCode(); if (getPass() != null) hc = hc * 31 + getPass().hashCode(); if (getHost() != null) hc = hc * 31 + getHost().hashCode(); if (getPort() > 0) hc = hc * 31 + getPort(); if (getPath() != null) hc = hc * 31 + getPath().hashCode(); return hc; }
private String format(boolean includePassword, boolean escapeNonAscii) { final StringBuilder r = new StringBuilder(); if (getScheme() != null) { r.append(getScheme()); r.append("://"); //$NON-NLS-1$ r.append('@'); r.append(escape(getHost(), false, escapeNonAscii)); if (getScheme() != null && getPort() > 0) { r.append(':'); r.append(getPort()); if (getScheme() != null) { if (!getPath().startsWith("/") && !getPath().isEmpty()) //$NON-NLS-1$ r.append('/'); } else if (getHost() != null) r.append(':'); if (getScheme() != null) if (escapeNonAscii) r.append(escape(getPath(), false, escapeNonAscii));
private void updateSslVerify(StoredConfig config, boolean value) { // Since git uses the original URI for matching, we must also use the // original URI and cannot use the current URI (which might be different // after redirects). String uriPattern = uri.getScheme() + "://" + uri.getHost(); //$NON-NLS-1$ int port = uri.getPort(); if (port > 0) { uriPattern += ":" + port; //$NON-NLS-1$ } config.setBoolean(HttpConfig.HTTP, uriPattern, HttpConfig.SSL_VERIFY_KEY, value); try { config.save(); } catch (IOException e) { LOG.error(JGitText.get().sslVerifyCannotSave, e); } }
if (!getSchemes().isEmpty() && !getSchemes().contains(uri.getScheme())) return false;
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (!(obj instanceof URIish)) return false; final URIish b = (URIish) obj; if (!eq(getScheme(), b.getScheme())) return false; if (!eq(getUser(), b.getUser())) return false; if (!eq(getPass(), b.getPass())) return false; if (!eq(getHost(), b.getHost())) return false; if (getPort() != b.getPort()) return false; if (!eq(getPath(), b.getPath())) return false; return true; }
/** * @param uri * URI to match against this protocol * @return {@code true} if the uri is handled by this protocol */ public boolean handles(URIish uri) { return getDefaultScheme().equals(uri.getScheme()); }
String commandFor(String exe) { String path = uri.getPath(); if (uri.getScheme() != null && uri.getPath().startsWith("/~")) //$NON-NLS-1$ path = (uri.getPath().substring(1)); final StringBuilder cmd = new StringBuilder(); cmd.append(exe); cmd.append(' '); cmd.append(QuotedString.BOURNE.quote(path)); return cmd.toString(); }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
public Transport open(URIish uri) throws NotSupportedException, TransportException { if ("bundle".equals(uri.getScheme())) { //$NON-NLS-1$ File path = FS.DETECTED.resolve(new File("."), uri.getPath()); //$NON-NLS-1$ return new TransportBundleFile(uri, path); } return TransportLocal.PROTO_LOCAL.open(uri); } };
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getScheme() == null) { // scp-style URI "host:path" does not have scheme. return uri.getHost() != null && uri.getPath() != null && uri.getHost().length() != 0 && uri.getPath().length() != 0; } return super.canHandle(uri, local, remoteName); }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getScheme() == null) { // scp-style URI "host:path" does not have scheme. return uri.getHost() != null && uri.getPath() != null && uri.getHost().length() != 0 && uri.getPath().length() != 0; } return super.canHandle(uri, local, remoteName); }