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