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


Java GitRepository.getCurrentRevision方法代码示例

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


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

示例1: readBranches

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@NotNull
private Set<VcsRef> readBranches(@NotNull GitRepository repository) {
  StopWatch sw = StopWatch.start("readBranches in " + repository.getRoot().getName());
  VirtualFile root = repository.getRoot();
  repository.update();
  Collection<GitLocalBranch> localBranches = repository.getBranches().getLocalBranches();
  Collection<GitRemoteBranch> remoteBranches = repository.getBranches().getRemoteBranches();
  Set<VcsRef> refs = new THashSet<VcsRef>(localBranches.size() + remoteBranches.size());
  for (GitLocalBranch localBranch : localBranches) {
    refs.add(myVcsObjectsFactory.createRef(localBranch.getHash(), localBranch.getName(), GitRefManager.LOCAL_BRANCH, root));
  }
  for (GitRemoteBranch remoteBranch : remoteBranches) {
    refs.add(
      myVcsObjectsFactory.createRef(remoteBranch.getHash(), remoteBranch.getNameForLocalOperations(), GitRefManager.REMOTE_BRANCH, root));
  }
  String currentRevision = repository.getCurrentRevision();
  if (currentRevision != null) { // null => fresh repository
    refs.add(myVcsObjectsFactory.createRef(HashImpl.build(currentRevision), "HEAD", GitRefManager.HEAD, root));
  }
  sw.report();
  return refs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GitLogProvider.java

示例2: GitPushOperation

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
public GitPushOperation(@NotNull Project project,
                        @NotNull GitPushSupport pushSupport,
                        @NotNull Map<GitRepository, PushSpec<GitPushSource, GitPushTarget>> pushSpecs,
                        @Nullable GitPushTagMode tagMode,
                        boolean force) {
  myProject = project;
  myPushSupport = pushSupport;
  myPushSpecs = pushSpecs;
  myTagMode = tagMode;
  myForce = force;
  myGit = ServiceManager.getService(Git.class);
  myProgressIndicator = ObjectUtils.notNull(ProgressManager.getInstance().getProgressIndicator(), new EmptyProgressIndicator());
  mySettings = GitVcsSettings.getInstance(myProject);
  myPlatformFacade = ServiceManager.getService(project, GitPlatformFacade.class);
  myRepositoryManager = ServiceManager.getService(myProject, GitRepositoryManager.class);

  Map<GitRepository, GitRevisionNumber> currentHeads = ContainerUtil.newHashMap();
  for (GitRepository repository : pushSpecs.keySet()) {
    repository.update();
    String head = repository.getCurrentRevision();
    if (head == null) {
      LOG.error("This repository has no commits");
    }
    else {
      currentHeads.put(repository, new GitRevisionNumber(head));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GitPushOperation.java

示例3: getCurrentBranch

import git4idea.repo.GitRepository; //导入方法依赖的package包/类
@Nullable
@Override
public String getCurrentBranch(@NotNull VirtualFile root) {
  GitRepository repository = myRepositoryManager.getRepositoryForRoot(root);
  if (repository == null) return null;
  String currentBranchName = repository.getCurrentBranchName();
  if (currentBranchName == null && repository.getCurrentRevision() != null) {
    return "HEAD";
  }
  return currentBranchName;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GitLogProvider.java


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