Java Code Examples for org.eclipse.jgit.transport.URIish#getPath()
The following examples show how to use
org.eclipse.jgit.transport.URIish#getPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitUtils.java From orion.server with Eclipse Public License 1.0 | 6 votes |
/** * Returns whether or not the git repository URI is forbidden. If a scheme of the URI is matched, check if the scheme is a supported protocol. Otherwise, * match for a scp-like ssh URI: [user@]host.xz:path/to/repo.git/ and ensure the URI does not represent a local file path. * * @param uri * A git repository URI * @return a boolean of whether or not the git repository URI is forbidden. */ public static boolean isForbiddenGitUri(URIish uri) { String scheme = uri.getScheme(); String host = uri.getHost(); String path = uri.getPath(); boolean isForbidden = false; if (scheme != null) { isForbidden = !uriSchemeWhitelist.contains(scheme); } else { // match for a scp-like ssh URI if (host != null) { isForbidden = host.length() == 1 || path == null; } else { isForbidden = true; } } return isForbidden; }
Example 2
Source File: CodeCommitEvent.java From aws-codecommit-trigger-plugin with Apache License 2.0 | 6 votes |
@Override public boolean isMatch(final URIish uri) { if (uri == null) { return false; } if (!StringUtils.equals(this.host, uri.getHost())) { log.debug("Event %s not match host %s", this.getArn(), uri.getHost()); return false; } // from https://github.com/riboseinc/aws-codecommit-trigger-plugin/issues/54#issuecomment-546503407 // ignore the difference of the last slash String p1 = this.path.endsWith("/") ? this.path : this.path + "/"; String p2 = uri.getPath().endsWith("/") ? uri.getPath() : uri.getPath() + "/"; if (!StringUtils.equalsIgnoreCase(p1, p2)) { log.debug("Event %s not match path %s", this.getArn(), uri.getPath()); return false; } log.debug("Event %s match uri %s", this.getArn(), uri); return true; }
Example 3
Source File: GithubUtil.java From aeron with Apache License 2.0 | 6 votes |
public static String getWikiUriFromOriginUri(final String remoteUri) throws URISyntaxException { final URIish urIish = new URIish(remoteUri); final String uriPath = urIish.getPath(); if (uriPath.endsWith("/")) { throw new IllegalArgumentException("unable to handle URI path ending in '/': " + remoteUri); } final int lastSlashIndex = urIish.getPath().lastIndexOf('/'); final String path = lastSlashIndex == -1 ? "" : uriPath.substring(0, lastSlashIndex + 1); final String prefixedPath = path.startsWith("/") ? path : "/" + path; final String repoName = lastSlashIndex == -1 ? uriPath : uriPath.substring(lastSlashIndex + 1); final String name = stripSuffix(repoName, ".git"); final String host = stripSuffix(urIish.getHost(), "/"); final String wikiUri = "https://" + host + prefixedPath + name + ".wiki.git"; System.out.println("Origin: " + remoteUri); System.out.println("Wiki : " + wikiUri); return wikiUri; }
Example 4
Source File: GitRepository.java From CardinalPGM with MIT License | 6 votes |
private static String format(URIish uri) { StringBuilder r = new StringBuilder(); if (uri.getScheme() != null) r.append(uri.getScheme()).append("://"); if (uri.getHost() != null) { r.append(uri.getHost()); if (uri.getScheme() != null && uri.getPort() > 0) r.append(':').append(uri.getPort()); } if (uri.getPath() != null) { if (uri.getScheme() != null) { if (!uri.getPath().startsWith("/") && !uri.getPath().isEmpty()) r.append('/'); } else if(uri.getHost() != null) r.append(':'); if (uri.getScheme() != null) r.append(uri.getRawPath()); else r.append(uri.getPath()); } return r.toString(); }
Example 5
Source File: PreemptiveAuthHttpClientConnection.java From git-client-plugin with MIT License | 6 votes |
static URIish goUp(final URIish uri) { final String originalPath = uri.getPath(); if (originalPath == null || originalPath.length() == 0 || originalPath.equals(SLASH)) { return null; } final int lastSlash; if (originalPath.endsWith(SLASH)) { lastSlash = originalPath.lastIndexOf(SLASH, originalPath.length() - 2); } else { lastSlash = originalPath.lastIndexOf(SLASH); } final String pathUpOneLevel = originalPath.substring(0, lastSlash); final URIish result; if (pathUpOneLevel.length() == 0) { result = uri.setPath(null); } else { result = uri.setPath(pathUpOneLevel); } return result; }