org.eclipse.jgit.api.Git.remoteList()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.eclipse.jgit.api.Git.remoteList()方法的一些代码示例,展示了Git.remoteList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.remoteList()方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:remoteList

Git.remoteList介绍

[英]Return a command used to list the available remotes.
[中]返回用于列出可用远程设备的命令。

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory remoteList() throws GitAPIException {
  RemoteListCommand command = getWrappedObject().remoteList();
  List<RemoteConfig> call = command.call();
  return GitUtils.valueOfRemoteConfigs(call);
}

代码示例来源:origin: kiegroup/appformer

public RemoteListCommand _remoteList() {
  return git.remoteList();
}

代码示例来源:origin: org.apache.camel/camel-git

protected void doRemoteList(Exchange exchange, String operation) throws Exception {
  List<RemoteConfig> result = null;
  try {
    result = git.remoteList().call();
  } catch (Exception e) {
    LOG.error("There was an error in Git {} operation", operation);
    throw e;
  }
  updateExchange(exchange, result);
}

代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin

private RemoteConfig getRemote(Git git, String name) {
  List<RemoteConfig> remotes;
  try {
    remotes = git.remoteList().call();
  } catch (GitAPIException e) {
    throw new IllegalStateException(e);
  }
  for (RemoteConfig remote: remotes) {
    if (remote.getName().equals(name)) {
      return remote;
    }
  }
  return null;
}

代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin

/**
 * Checks if the upstream repo exist and if there is a proper URL
 */
private boolean isUpstreamRepoCreated(Git git, String path) throws Exception {
  try {
    List<RemoteConfig> remotes = git.remoteList().call();
    for(RemoteConfig remote : remotes){
      if(remote.getName().equals(UPSTREAM)){
        for(URIish uri : remote.getURIs()){
          if(uri.toString().equals(getRemoteRepoUrlFromPom(path))){
            return true;
          }else {
            deleteUpstreamRepo(git);
          }
        }
      }
    }
  } catch (GitAPIException e) {
    throw new Exception(CREATING_REMOTE_UPSTREAM_REASON, e);
  }
  return false;
}

代码示例来源:origin: org.apache.nifi.registry/nifi-registry-framework

final List<RemoteConfig> remotes = git.remoteList().call();
final boolean isRemoteExist = remotes.stream().anyMatch(remote -> remote.getName().equals(remoteToPush));
if (!isRemoteExist) {

代码示例来源:origin: danielflower/app-runner

public static BackupService prepare(File localDir, URIish remoteUri, int backupTimeInMinutes) throws GitAPIException, IOException {
    Git local;
    try {
      local = Git.open(localDir);
    } catch (RepositoryNotFoundException e) {
      log.info("Initialising " + fullPath(localDir) + " as a git repo for backup purposes");
      local = Git.init().setDirectory(localDir).setBare(false).call();
    }
    log.info("Setting backup URL to " + remoteUri);
    if (local.remoteList().call().stream().anyMatch(remoteConfig -> remoteConfig.getName().equals("origin"))) {
      RemoteSetUrlCommand remoteSetUrlCommand = local.remoteSetUrl();
      remoteSetUrlCommand.setName("origin");
      remoteSetUrlCommand.setUri(remoteUri);
      remoteSetUrlCommand.call();
    } else {
      RemoteAddCommand remoteAddCommand = local.remoteAdd();
      remoteAddCommand.setName("origin");
      remoteAddCommand.setUri(remoteUri);
      remoteAddCommand.call();
    }

    URL inputUrl = BackupService.class.getResource("/dataDirGitIgnore.txt");
    FileUtils.copyURLToFile(inputUrl, new File(localDir, ".gitignore"));

    return new BackupService(local, remoteUri.toString(), backupTimeInMinutes);
  }
}

代码示例来源:origin: synchrony/smsn

private void addOrigin() throws URISyntaxException, GitAPIException {
    RemoteAddCommand add = git.remoteAdd();
    add.setName("origin");
    String uri = "https://example.org/repo";
    add.setUri(new URIish(uri));
    add.call();
    assertEquals("origin", git.remoteList().call().iterator().next().getName());
    assertEquals(uri, git.remoteList().call().iterator().next().getURIs().iterator().next().toString());
  }
}

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

@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,
       null).execute();
  final Git cloned = Git.open(directory);
  assertThat(cloned).isNotNull();
  assertThat(new ListRefs(cloned.getRepository()).execute()).is(new Condition<List<? extends Ref>>() {
    @Override
    public boolean matches(final List<? extends 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);
}

代码示例来源:origin: kiegroup/appformer

@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,
       null).execute();
  final Git cloned = Git.open(directory);
  assertThat(cloned).isNotNull();
  assertThat(new ListRefs(cloned.getRepository()).execute()).is(new Condition<List<? extends Ref>>() {
    @Override
    public boolean matches(final List<? extends 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);
}

代码示例来源:origin: kiegroup/appformer

URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0);
String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath();
assertThat(remoteUrl).isEqualTo(ORIGIN);

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

@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,
       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);
}

代码示例来源:origin: kiegroup/appformer

@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,
       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);
}

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

URIish remoteUri = cloned.remoteList().call().get(0).getURIs().get(0);
String remoteUrl = remoteUri.getScheme() + "://" + remoteUri.getHost() + remoteUri.getPath();
assertThat(remoteUrl).isEqualTo(ORIGIN);

相关文章