當前位置: 首頁>>代碼示例>>Java>>正文


Java URIish.getPath方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.transport.URIish.getPath方法的典型用法代碼示例。如果您正苦於以下問題:Java URIish.getPath方法的具體用法?Java URIish.getPath怎麽用?Java URIish.getPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.transport.URIish的用法示例。


在下文中一共展示了URIish.getPath方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGerritProjectName

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public static String getGerritProjectName(Repository repository) {
	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) {
			if (uri.getPort() == 29418) { //Gerrit refspec
				String path = uri.getPath();
				while (path.startsWith("/")) { //$NON-NLS-1$
					path = path.substring(1);
				}
				return path;
			}
			break;
		}
	} catch (Exception e) {
		GerritToolsPlugin.getDefault().log(e);
	}
	return null;
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:24,代碼來源:GerritUtils.java

示例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();
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:22,代碼來源:GitRepository.java

示例3: goUp

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
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;
}
 
開發者ID:jenkinsci,項目名稱:git-client-plugin,代碼行數:23,代碼來源:PreemptiveAuthHttpClientConnection.java

示例4: createLocally

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static void createLocally(URIish uri, String head) {
  try (Repository repo = new FileRepository(uri.getPath())) {
    repo.create(true /* bare */);

    if (head != null) {
      RefUpdate u = repo.updateRef(Constants.HEAD);
      u.disableRefLog();
      u.link(head);
    }
  } catch (IOException e) {
    repLog.error(String.format("Error creating local repository %s:\n", uri.getPath()), e);
  }
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:14,代碼來源:ReplicationQueue.java

示例5: updateHeadLocally

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static void updateHeadLocally(URIish uri, String newHead) {
  try (Repository repo = new FileRepository(uri.getPath())) {
    if (newHead != null) {
      RefUpdate u = repo.updateRef(Constants.HEAD);
      u.link(newHead);
    }
  } catch (IOException e) {
    repLog.error(
        String.format("Failed to update HEAD of repository %s to %s", uri.getPath(), newHead), e);
  }
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:12,代碼來源:ReplicationQueue.java

示例6: 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;
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:14,代碼來源:ReplicationQueue.java

示例7: 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);
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:36,代碼來源:JGitMirrorTest.java

示例8: 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);
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:38,代碼來源:JGitMirrorTest.java

示例9: 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);
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:29,代碼來源:JGitMirrorTest.java

示例10: getRepositoryBase

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
/**
 * Gets the base directory of the specified reposotory's file location.
 * 
 * @param gitRepository the repository. Must not be {@code null}
 * @return the base file. Never {@code null}
 * @throws URISyntaxException
 */
public static File getRepositoryBase(final GitRepository gitRepository) throws URISyntaxException {
	Validate.notNull(gitRepository, "gitRepository must not be null");
	
	final URIish uri = new URIish(gitRepository.getUri());
	if (!"file".equals(uri.getScheme())) {
		throw new IllegalArgumentException("Only file:// URI scheme supported");
	}
	final File repositoryDirectory = new File(uri.getPath());
	return repositoryDirectory;
}
 
開發者ID:astralbat,項目名稱:gitcommitviewer,代碼行數:18,代碼來源:RepositoryTestUtils.java


注:本文中的org.eclipse.jgit.transport.URIish.getPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。