List of usage examples for org.eclipse.jgit.transport URIish isRemote
public boolean isRemote()
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());//w w w.j av a2 s. c om if (uri.getPort() != -1) { sb.append(":"); sb.append(uri.getPort()); } } else { sb.append(uri.getPath()); } return sb.toString(); }
From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java
License:Apache License
private boolean createProject(URIish replicateURI, String head) { if (!replicateURI.isRemote()) { createLocally(replicateURI, head); repLog.info("Created local repository: " + replicateURI); } else if (isSSH(replicateURI)) { createRemoteSsh(replicateURI, head); repLog.info("Created remote repository: " + replicateURI); } else {/*from w w w . j a v a 2 s . com*/ repLog.warn(String.format("Cannot create new project on remote site %s." + " Only local paths and SSH URLs are supported" + " for remote repository creation", replicateURI)); return false; } return true; }
From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java
License:Apache License
private void deleteProject(URIish replicateURI) { if (!replicateURI.isRemote()) { deleteLocally(replicateURI);//www .j av a 2s. c om repLog.info("Deleted local repository: " + replicateURI); } else if (isSSH(replicateURI)) { deleteRemoteSsh(replicateURI); repLog.info("Deleted remote repository: " + replicateURI); } else { repLog.warn(String.format("Cannot delete project on remote site %s." + " Only local paths and SSH URLs are supported" + " for remote repository deletion", replicateURI)); } }
From source file:com.googlesource.gerrit.plugins.replication.ReplicationQueue.java
License:Apache License
private void updateHead(URIish replicateURI, String newHead) { if (!replicateURI.isRemote()) { updateHeadLocally(replicateURI, newHead); } else if (isSSH(replicateURI)) { updateHeadRemoteSsh(replicateURI, newHead); } else {/* www . j ava 2 s . co m*/ repLog.warn(String.format( "Cannot update HEAD of project on remote site %s." + " Only local paths and SSH URLs are supported" + " for remote HEAD update.", replicateURI)); } }
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; }/*from ww w .j av a 2s .c o m*/ 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:jetbrains.buildServer.buildTriggers.vcs.git.GitUrlSupport.java
License:Apache License
private boolean isScpSyntax(URIish uriish) { return uriish.getScheme() == null && uriish.isRemote(); }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.TransportFactoryImpl.java
License:Apache License
/** * This is a work-around for an issue http://youtrack.jetbrains.net/issue/TW-9933. * Due to bug in jgit (https://bugs.eclipse.org/bugs/show_bug.cgi?id=315564), * in the case of not-existing local repository we get an obscure exception: * 'org.eclipse.jgit.errors.NotSupportedException: URI not supported: x:/git/myrepo.git', * while URI is correct./*from w w w. j a v a2 s. c o m*/ * * It often happens when people try to access a repository located on a mapped network * drive from the TeamCity started as Windows service. * * If repository is local and is not exists this method throws a friendly exception. * * @param url URL to check * @throws VcsException if url points to not-existing local repository */ private void checkUrl(final URIish url) throws VcsException { String scheme = url.getScheme(); if (!url.isRemote() && !"http".equals(scheme) && !"https".equals(scheme)) { File localRepository = new File(url.getPath()); if (!localRepository.exists()) { String error = "Cannot access the '" + url.toString() + "' repository"; if (SystemInfo.isWindows) { error += ". If TeamCity is run as a Windows service, it cannot access network mapped drives. Make sure this is not your case."; } throw new VcsException(error); } } }
From source file:org.eclipse.egit.core.internal.util.RepositoryPathChecker.java
License:Open Source License
private boolean isURL(String dir) { try {/*from w ww .ja va2s . c o m*/ URIish u = new URIish(dir); return u.isRemote() || u.getScheme() != null; } catch (URISyntaxException e) { // skip } return false; }
From source file:org.z2env.impl.gitcr.GitComponentRepositoryImpl.java
License:Apache License
private static URIish getOrigRepo(String name, Properties props, boolean isOptional) { String uri = normalize(props.getProperty(GITCR_URI)); logger.fine("read GitCR " + name + "::" + GITCR_URI + " = " + uri); if (uri == null) { throw new IllegalStateException("Missing property " + GITCR_URI + " in " + name); }//from ww w.jav a 2 s . c o m URIish uriish; try { uriish = new URIish(uri); } catch (URISyntaxException e1) { throw new IllegalStateException("Git-CR '" + name + ": '" + uri + "' is not a valid Git-URI"); } // try normalize to work relative to Z2 home if (!uriish.isRemote()) { try { File f = new File(uri); if (!f.isAbsolute()) { // relative! String zHome = normalize(System.getProperty(Foundation.HOME)); if (zHome != null) { f = new File(new File(zHome), uri); } else { f = new File(uri); } } uri = f.getCanonicalPath(); uriish = new URIish(uri); } catch (Exception e1) { throw new IllegalStateException("Git-CR '" + name + ": '" + uri + "' is not a valid Git-URI"); } } if (isOptional) { // skip all checks for optional repositories return uriish; } boolean canHandle = false; for (TransportProtocol transp : Transport.getTransportProtocols()) { if (transp.canHandle(uriish)) { if (!canHandle && transp.getSchemes().contains("file")) { // do some checks in advance File gitDir = new File(uri); String absPath = null; try { absPath = gitDir.getCanonicalPath(); } catch (IOException e) { throw new IllegalStateException("Git-CR '" + name + ": The path " + gitDir + " defined in " + name + "::" + GITCR_URI + " cannot be canonicalized!", e); } if (!gitDir.exists()) { throw new IllegalStateException("Git-CR '" + name + ": The path " + gitDir + " (abs-path: " + absPath + ") defined in " + name + "::" + GITCR_URI + " does not exists!"); } if (!gitDir.isDirectory()) { throw new IllegalStateException("Git-CR '" + name + ": The path " + gitDir + " (abs-path: " + absPath + ") defined in " + name + "::" + GITCR_URI + " is not a directory!"); } if (!gitDir.canRead()) { throw new IllegalStateException("Git-CR '" + name + ": The path " + gitDir + " (abs-path: " + absPath + ") defined in " + name + "::" + GITCR_URI + " cannot be accessed! Please check permissions."); } } canHandle = true; } } if (!canHandle) { throw new IllegalStateException("Git-CR '" + name + ": The uri " + uri + " defined in " + GITCR_URI + " cannot be handled by this git implementation!"); } return uriish; }