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


Java GitBranchUtil.getTrackedRemoteName方法代码示例

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


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

示例1: pushSpecsForCurrentOrEnteredBranches

import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
private Map<GitRepository, GitPushSpec> pushSpecsForCurrentOrEnteredBranches() throws VcsException {
  Map<GitRepository, GitPushSpec> defaultSpecs = new HashMap<GitRepository, GitPushSpec>();
  for (GitRepository repository : myRepositories) {
    GitLocalBranch currentBranch = repository.getCurrentBranch();
    if (currentBranch == null) {
      continue;
    }
    String remoteName = GitBranchUtil.getTrackedRemoteName(repository.getProject(), repository.getRoot(), currentBranch.getName());
    String trackedBranchName = GitBranchUtil.getTrackedBranchName(repository.getProject(), repository.getRoot(), currentBranch.getName());
    GitRemote remote = GitUtil.findRemoteByName(repository, remoteName);
    GitRemoteBranch targetBranch;
    if (remote != null && trackedBranchName != null) {
      targetBranch = GitBranchUtil.findRemoteBranchByName(trackedBranchName, remote.getName(),
                                                          repository.getBranches().getRemoteBranches());
    }
    else {
      Pair<GitRemote, GitRemoteBranch> remoteAndBranch = GitUtil.findMatchingRemoteBranch(repository, currentBranch);
      if (remoteAndBranch == null) {
        targetBranch = GitPusher.NO_TARGET_BRANCH;
      } else {
        targetBranch = remoteAndBranch.getSecond();
      }
    }

    if (myRefspecPanel.turnedOn()) {
      String manualBranchName = myRefspecPanel.getBranchToPush();
      remote = myRefspecPanel.getSelectedRemote();
      GitRemoteBranch manualBranch = GitBranchUtil.findRemoteBranchByName(manualBranchName, remote.getName(),
                                                                          repository.getBranches().getRemoteBranches());
      if (manualBranch == null) {
        manualBranch = new GitStandardRemoteBranch(remote, manualBranchName, GitBranch.DUMMY_HASH);
      }
      targetBranch = manualBranch;
    }

    GitPushSpec pushSpec = new GitPushSpec(currentBranch, targetBranch == null ? GitPusher.NO_TARGET_BRANCH : targetBranch);
    defaultSpecs.put(repository, pushSpec);
  }
  return defaultSpecs;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:GitPushDialog.java

示例2: findMatchingRemoteBranch

import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
/**
 * @deprecated Calls Git for tracked info, use {@link GitRepository#getBranchTrackInfos()} instead.
 */
@Nullable
@Deprecated
public static Pair<GitRemote, GitRemoteBranch> findMatchingRemoteBranch(GitRepository repository, GitLocalBranch branch)
  throws VcsException {
  /*
  from man git-push:
  git push
             Works like git push <remote>, where <remote> is the current branch's remote (or origin, if no
             remote is configured for the current branch).

   */
  String remoteName = GitBranchUtil.getTrackedRemoteName(repository.getProject(), repository.getRoot(), branch.getName());
  GitRemote remote;
  if (remoteName == null) {
    remote = findOrigin(repository.getRemotes());
  } else {
    remote = findRemoteByName(repository, remoteName);
  }
  if (remote == null) {
    return null;
  }

  for (GitRemoteBranch remoteBranch : repository.getBranches().getRemoteBranches()) {
    if (remoteBranch.getName().equals(remote.getName() + "/" + branch.getName())) {
      return Pair.create(remote, remoteBranch);
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:GitUtil.java

示例3: getRejectedPushesFromCurrentBranchToTrackedBranch

import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@NotNull
Map<GitRepository, GitBranch> getRejectedPushesFromCurrentBranchToTrackedBranch(GitPushInfo pushInfo) {
  final Map<GitRepository, GitBranch> rejectedPushesForCurrentBranch = new HashMap<GitRepository, GitBranch>();
  for (Map.Entry<GitRepository, GitPushRepoResult> entry : group().myRejectedResults.entrySet()) {
    GitRepository repository = entry.getKey();
    GitBranch currentBranch = repository.getCurrentBranch();
    if (currentBranch == null) {
      continue;
    }
    GitPushRepoResult repoResult = entry.getValue();
    GitPushBranchResult curBranchResult = repoResult.getBranchResults().get(currentBranch);

    if (curBranchResult == null) {
      continue;
    }

    String trackedBranchName;
    try {
      String simpleName = GitBranchUtil.getTrackedBranchName(myProject, repository.getRoot(), currentBranch.getName());
      if (simpleName == null) {
        continue;
      }
      if (simpleName.startsWith(GitBranch.REFS_HEADS_PREFIX)) {
        simpleName = simpleName.substring(GitBranch.REFS_HEADS_PREFIX.length());
      }
      String remote = GitBranchUtil.getTrackedRemoteName(myProject, repository.getRoot(), currentBranch.getName());
      if (remote == null) {
        continue;
      }
      trackedBranchName = remote + "/" + simpleName;
    }
    catch (VcsException e) {
      LOG.info("Couldn't get tracked branch for branch " + currentBranch, e);
      continue;
    }
    if (!pushInfo.getPushSpecs().get(repository).getDest().getName().equals(trackedBranchName)) {
      // push from current branch was rejected, but it was a push not to the tracked branch => ignore
      continue;
    }
    if (curBranchResult.isRejected()) {
      rejectedPushesForCurrentBranch.put(repository, currentBranch);
    }
  }
  return rejectedPushesForCurrentBranch;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:GitPushResult.java


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