本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}