当前位置: 首页>>代码示例>>Java>>正文


Java GitRepository.getRemotes方法代码示例

本文整理汇总了Java中git4idea.repo.GitRepository.getRemotes方法的典型用法代码示例。如果您正苦于以下问题:Java GitRepository.getRemotes方法的具体用法?Java GitRepository.getRemotes怎么用?Java GitRepository.getRemotes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git4idea.repo.GitRepository的用法示例。


在下文中一共展示了GitRepository.getRemotes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findGithubRemote

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@Nullable
public static Pair<GitRemote, String> findGithubRemote(@NotNull GitRepository repository) {
  Pair<GitRemote, String> githubRemote = null;
  for (GitRemote gitRemote : repository.getRemotes()) {
    for (String remoteUrl : gitRemote.getUrls()) {
      if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
        final String remoteName = gitRemote.getName();
        if ("github".equals(remoteName) || "origin".equals(remoteName)) {
          return Pair.create(gitRemote, remoteUrl);
        }
        if (githubRemote == null) {
          githubRemote = Pair.create(gitRemote, remoteUrl);
        }
        break;
      }
    }
  }
  return githubRemote;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GithubUtil.java

示例2: proposeTargetForNewBranch

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private static GitPushTarget proposeTargetForNewBranch(GitRepository repository, GitLocalBranch currentBranch) {
  Collection<GitRemote> remotes = repository.getRemotes();
  if (remotes.isEmpty()) {
    return null; // TODO need to propose to declare new remote
  }
  else if (remotes.size() == 1) {
    return makeTargetForNewBranch(repository, remotes.iterator().next(), currentBranch);
  }
  else {
    GitRemote remote = GitUtil.getDefaultRemote(remotes);
    if (remote == null) {
      remote = remotes.iterator().next();
    }
    return makeTargetForNewBranch(repository, remote, currentBranch);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitPushSupport.java

示例3: fetchAll

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@NotNull
private GitFetchResult fetchAll(@NotNull GitRepository repository, @NotNull GitFetchResult fetchResult) {
  for (GitRemote remote : repository.getRemotes()) {
    String url = remote.getFirstUrl();
    if (url == null) {
      LOG.error("URL is null for remote " + remote.getName());
      continue;
    }
    GitFetchResult res = fetchNatively(repository, remote, null);
    res.addPruneInfo(fetchResult.getPrunedRefs());
    fetchResult = res;
    if (!fetchResult.isSuccess()) {
      break;
    }
  }
  return fetchResult;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GitFetcher.java

示例4: getCurrentOrDefaultRemote

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
/**
 * If the current branch is a tracking branch, returns its remote.
 * Otherwise tries to guess: if there is origin, returns origin, otherwise returns the first remote in the list.
 */
@Nullable
private static GitRemote getCurrentOrDefaultRemote(@NotNull GitRepository repository) {
  Collection<GitRemote> remotes = repository.getRemotes();
  if (remotes.isEmpty()) {
    return null;
  }

  GitBranchTrackInfo trackInfo = GitUtil.getTrackInfoForCurrentBranch(repository);
  if (trackInfo != null) {
    return trackInfo.getRemote();
  }
  else {
    GitRemote origin = GitUtil.getDefaultRemote(remotes);
    if (origin != null) {
      return origin;
    }
    else {
      return remotes.iterator().next();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GitPullDialog.java

示例5: findUpstreamRemote

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@Nullable
public static String findUpstreamRemote(@NotNull GitRepository repository) {
  for (GitRemote gitRemote : repository.getRemotes()) {
    final String remoteName = gitRemote.getName();
    if ("upstream".equals(remoteName)) {
      for (String remoteUrl : gitRemote.getUrls()) {
        if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
          return remoteUrl;
        }
      }
      return gitRemote.getFirstUrl();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GithubUtil.java

示例6: collectApplicationNames

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
public List<String> collectApplicationNames(@NotNull GitRepository repository) {
  List<String> result = new ArrayList<String>();
  for (GitRemote remote : repository.getRemotes()) {
    for (String url : remote.getUrls()) {
      Matcher matcher = myGitUrlPattern.matcher(url);
      if (matcher.matches()) {
        result.add(matcher.group(1));
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CloudGitDeploymentDetector.java

示例7: updateRemotes

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private void updateRemotes() {
  GitRepository repository = getRepository();
  if (repository == null) {
    return;
  }

  GitRemote currentRemote = getCurrentOrDefaultRemote(repository);
  myRemote.setRenderer(getGitRemoteListCellRenderer(currentRemote != null ? currentRemote.getName() : null));
  myRemote.removeAllItems();
  for (GitRemote remote : repository.getRemotes()) {
    myRemote.addItem(remote);
  }
  myRemote.setSelectedItem(currentRemote);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GitPullDialog.java

示例8: getRemoteByName

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@Nullable
private static GitRemote getRemoteByName(@NotNull GitRepository repository, @NotNull String remoteName) {
  for (GitRemote remote : repository.getRemotes()) {
    if (remote.getName().equals(remoteName)) {
      return remote;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GitDeleteRemoteBranchOperation.java


注:本文中的git4idea.repo.GitRepository.getRemotes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。