Example usage for org.eclipse.jgit.transport URIish setScheme

List of usage examples for org.eclipse.jgit.transport URIish setScheme

Introduction

In this page you can find the example usage for org.eclipse.jgit.transport URIish setScheme.

Prototype

public URIish setScheme(String n) 

Source Link

Document

Return a new URI matching this one, but with a different scheme.

Usage

From source file:org.eclipse.egit.ui.internal.clone.GerritConfigurationPage.java

License:Open Source License

private void setDefaults(RepositorySelection selection) {
    URIish uri = selection.getURI();/* w  w  w  .j  a  v  a 2  s.  c om*/
    URIish newPushURI = uri;
    if (Protocol.SSH.handles(uri)) {
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (Protocol.GIT.handles(uri)) {
        newPushURI = newPushURI.setScheme(Protocol.SSH.getDefaultScheme());
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (isHttpProtocol(uri)) {
        newPushURI = prependGerritHttpPathPrefix(newPushURI);
    }
    uriText.setText(newPushURI.toString());
    final String uriScheme = newPushURI.getScheme();
    if (uriScheme != null)
        scheme.select(scheme.indexOf(uriScheme));
    branch.setText(Constants.MASTER);
}

From source file:org.eclipse.egit.ui.internal.gerrit.GerritConfigurationPage.java

License:Open Source License

private void setDefaults(URIish uri, String targetBranch) {
    URIish newPushURI = uri;
    if (Protocol.SSH.handles(uri)) {
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (Protocol.GIT.handles(uri)) {
        newPushURI = newPushURI.setScheme(Protocol.SSH.getDefaultScheme());
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (isHttpProtocol(uri)) {
        newPushURI = prependGerritHttpPathPrefix(newPushURI);
    }/*from  w  w w .  j  ava 2  s.c o m*/
    uriText.setText(newPushURI.toString());
    final String uriScheme = newPushURI.getScheme();
    if (uriScheme != null)
        scheme.select(scheme.indexOf(uriScheme));
    branch.setText(targetBranch != null ? targetBranch : Constants.MASTER);
}

From source file:org.sonatype.m2e.egit.internal.EgitScmHandler.java

License:Open Source License

protected String normalizeUri(String uri) throws URISyntaxException {
    if (!uri.startsWith(GIT_SCM_ID)) {
        return uri;
    }/*  w w w.  j a v  a  2  s.c o m*/

    uri = uri.substring(GIT_SCM_ID.length());
    if (uri.startsWith("file:") && !uri.startsWith("file:///")) {
        throw new URISyntaxException(uri, "Invalid git URI");
    }

    URIish gitUri = new URIish(uri);
    if (gitUri.getScheme() == null) {
        if (gitUri.getHost() == null || "file".equals(gitUri.getHost())) {
            gitUri = gitUri.setHost(null);
            gitUri = gitUri.setScheme("file");
        } else {
            // This must be an scp-like syntax git URL
            // See http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a
            gitUri = gitUri.setScheme("ssh");
        }
    }
    return gitUri.toString();
}