List of usage examples for org.eclipse.jgit.transport URIish getHost
public String getHost()
From source file:com.genuitec.eclipse.gerrit.tools.utils.GerritUtils.java
License:Open Source License
public static String getGerritURL(Repository repository) { String best = null;//from w w w . ja v a 2 s . com try { RemoteConfig config = new RemoteConfig(repository.getConfig(), "origin"); //$NON-NLS-1$ List<URIish> urls = new ArrayList<URIish>(config.getPushURIs()); urls.addAll(config.getURIs()); for (URIish uri : urls) { best = "https://" + uri.getHost(); //$NON-NLS-1$ if (uri.getPort() == 29418) { //Gerrit refspec return best; } break; } } catch (Exception e) { GerritToolsPlugin.getDefault().log(e); } return best; }
From source file:com.google.gerrit.server.git.PushReplication.java
License:Apache License
private boolean usingSSH(final URIish uri) { final String scheme = uri.getScheme(); if (!uri.isRemote()) return false; if (scheme != null && scheme.toLowerCase().contains("ssh")) return true; if (scheme == null && uri.getHost() != null && uri.getPath() != null) return true; return false; }
From source file:com.googlesource.gerrit.plugins.replication.PushResultProcessing.java
License:Apache License
private static String resolveNodeName(URIish uri) { StringBuilder sb = new StringBuilder(); if (uri.isRemote()) { sb.append(uri.getHost()); if (uri.getPort() != -1) { sb.append(":"); sb.append(uri.getPort());/*from w w w . ja v a 2s. c om*/ } } else { sb.append(uri.getPath()); } return sb.toString(); }
From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java
License:Apache License
private static boolean isSSH(URIish uri) { String scheme = uri.getScheme(); if (!uri.isRemote()) { return false; }// w w w. jav a2 s.c om if (scheme != null && scheme.toLowerCase().contains("ssh")) { return true; } if (scheme == null && uri.getHost() != null && uri.getPath() != null) { return true; } return false; }
From source file:com.sap.poc.jgit.storage.jdbc.JdbcDatabaseBuilder.java
License:Eclipse Distribution License
public JdbcDatabaseBuilder setURI(final String uri) throws URISyntaxException { final URIish u = new URIish(uri); final String scheme = u.getScheme(); if (!scheme.startsWith(Main.GIT_JDBC_PREFIX)) throw new IllegalArgumentException(); final int beginVendor = scheme.lastIndexOf("+") + 1; final String vendor = scheme.substring(beginVendor); if (vendor.length() < 1) throw new IllegalArgumentException(); setVendor(vendor);/*from w w w . ja v a 2 s . c om*/ final String host = u.getHost(); if (host == null || host.length() < 1) throw new IllegalArgumentException(); final int port = u.getPort(); if (port == -1) throw new IllegalArgumentException(); setHost(host + ":" + port); String path = u.getPath(); if (path.startsWith("/")) path = path.substring(1); int endDbName = path.indexOf("/"); if (endDbName < 0) endDbName = path.length(); setDatabaseName(path.substring(0, endDbName)); return this; }
From source file:com.sap.poc.jgit.storage.jdbc.JdbcRepositoryBuilder.java
License:Eclipse Distribution License
public JdbcRepositoryBuilder setURI(final String uri) throws URISyntaxException { final URIish u = new URIish(uri); final String scheme = u.getScheme(); if (!scheme.startsWith(Main.GIT_JDBC_PREFIX)) throw new IllegalArgumentException(); final int beginVendor = scheme.lastIndexOf("+") + 1; final String vendor = scheme.substring(beginVendor); if (vendor.length() < 1) throw new IllegalArgumentException(); setVendor(vendor);//from ww w . j a va 2s. co m final String host = u.getHost(); if (host == null || host.length() < 1) throw new IllegalArgumentException(); final int port = u.getPort(); if (port == -1) throw new IllegalArgumentException(); setHost(host + ":" + port); String path = u.getPath(); if (path.startsWith("/")) path = path.substring(1); int endDbName = path.indexOf("/"); if (endDbName < 0) endDbName = path.length(); setDatabaseName(path.substring(0, endDbName)); final int beginRepoName = endDbName + 1; setRepositoryName(path.substring(beginRepoName)); return self(); }
From source file:io.relution.jenkins.awssqs.model.entities.codecommit.CodeCommitEvent.java
License:Apache License
@Override public boolean isMatch(final URIish uri) { if (uri == null) { return false; }/*from w w w . ja va2 s.c o m*/ if (!StringUtils.equals(this.host, uri.getHost())) { return false; } if (!StringUtils.equals(this.path, uri.getPath())) { return false; } return true; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.AuthSettings.java
License:Apache License
private boolean requiresCredentials(URIish result) { String scheme = result.getScheme(); return result.getHost() != null || scheme != null && !scheme.equals("git"); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.github.GitHubUtil.java
License:Apache License
@Nullable public static GitHubRepo getGitHubRepo(@NotNull URIish uri) throws VcsException { if (!"github.com".equals(uri.getHost())) return null; String path = uri.getPath();/*from ww w .j a v a 2 s . c o m*/ if (path == null) return null; if (path.startsWith("/")) path = path.substring(1); int idx = path.indexOf("/"); if (idx <= 0) return null; String owner = path.substring(0, idx); String repo = path.substring(idx + 1, path.length()); if (repo.endsWith(".git")) repo = repo.substring(0, repo.length() - 4); return new GitHubRepo(owner, repo); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.GitMapFullPath.java
License:Apache License
private boolean urlsMatch(@NotNull GitVcsRoot root, @NotNull FullPath fullPath) { String url = removeBranch(fullPath.getRepositoryUrl()); final URIish uri; try {/*from w w w. j av a2 s .c om*/ uri = new URIish(url); } catch (final URISyntaxException e) { if (ReferencesResolverUtil.containsReference(url)) { LOG.warn("Unresolved parameter in url " + url + ", root " + LogUtil.describe(root)); } else { LOG.warnAndDebugDetails( "Error while parsing VCS root url " + url + ", root " + LogUtil.describe(root), e); } return false; } final URIish settingsUrl = root.getRepositoryFetchURL(); if (settingsUrl == null) { return false; } if (uri.getHost() == null && settingsUrl.getHost() != null || uri.getHost() != null && !uri.getHost().equals(settingsUrl.getHost())) { return false; } if (uri.getPort() != settingsUrl.getPort()) { return false; } if (uri.getPath() == null && settingsUrl.getPath() != null || uri.getPath() != null && !uri.getPath().equals(settingsUrl.getPath())) { return false; } return true; }