本文整理匯總了Java中org.eclipse.jgit.transport.URIish.getScheme方法的典型用法代碼示例。如果您正苦於以下問題:Java URIish.getScheme方法的具體用法?Java URIish.getScheme怎麽用?Java URIish.getScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.transport.URIish
的用法示例。
在下文中一共展示了URIish.getScheme方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSshUri
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
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;
}
示例2: format
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
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();
}
示例3: isSSH
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static boolean isSSH(URIish uri) {
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;
}
示例4: testToHTTPMirrorSuccess
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
@Test
public void testToHTTPMirrorSuccess() throws IOException, GitAPIException {
final File parentFolder = createTempDirectory();
final File directory = new File(parentFolder,
TARGET_GIT);
new Clone(directory,
ORIGIN,
true,
CredentialsProvider.getDefault(),
null).execute();
final Git cloned = Git.open(directory);
assertThat(cloned).isNotNull();
assertThat(cloned.getRepository().getAllRefs()).is(new Condition<Map<String, Ref>>() {
@Override
public boolean matches(final Map<String, Ref> refs) {
final boolean hasMasterRef = refs.get("refs/heads/master") != null;
final boolean hasPullRequestRef = refs.get("refs/pull/1/head") != null;
return hasMasterRef && hasPullRequestRef;
}
});
final boolean isMirror = cloned.getRepository().getConfig().getBoolean("remote",
"origin",
"mirror",
false);
assertTrue(isMirror);
URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0);
String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath();
assertThat(remoteUrl).isEqualTo(ORIGIN);
}
示例5: testToHTTPUnmirrorSuccess
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
@Test
public void testToHTTPUnmirrorSuccess() throws IOException, GitAPIException {
final File parentFolder = createTempDirectory();
final File directory = new File(parentFolder,
TARGET_GIT);
new Clone(directory,
ORIGIN,
false,
CredentialsProvider.getDefault(),
null).execute();
final Git cloned = Git.open(directory);
assertThat(cloned).isNotNull();
assertThat(cloned.getRepository().getAllRefs()).is(new Condition<Map<String, Ref>>() {
@Override
public boolean matches(final Map<String, Ref> refs) {
final boolean hasMasterRef = refs.get("refs/heads/master") != null;
final boolean hasPullRequestRef = refs.get("refs/pull/1/head") != null;
return hasMasterRef && !hasPullRequestRef;
}
});
final boolean isMirror = cloned.getRepository().getConfig().getBoolean("remote",
"origin",
"mirror",
false);
assertFalse(isMirror);
assertThat(new ListRefs(cloned.getRepository()).execute().get(0).getName()).isEqualTo("refs/heads/master");
URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0);
String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath();
assertThat(remoteUrl).isEqualTo(ORIGIN);
}
示例6: testEmptyCredentials
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
@Test
public void testEmptyCredentials() throws IOException, GitAPIException {
final File parentFolder = createTempDirectory();
final File directory = new File(parentFolder,
TARGET_GIT);
new Clone(directory,
ORIGIN,
false,
null,
null).execute();
final Git cloned = Git.open(directory);
assertThat(cloned).isNotNull();
assertThat(new ListRefs(cloned.getRepository()).execute()).is(new Condition<List<Ref>>() {
@Override
public boolean matches(final List<Ref> refs) {
return refs.size() > 0;
}
});
assertThat(new ListRefs(cloned.getRepository()).execute().get(0).getName()).isEqualTo("refs/heads/master");
URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0);
String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath();
assertThat(remoteUrl).isEqualTo(ORIGIN);
}
示例7: isGerrit
import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static boolean isGerrit(URIish uri) {
String scheme = uri.getScheme();
return scheme != null && scheme.toLowerCase().equals("gerrit+ssh");
}