本文整理汇总了Java中git4idea.repo.GitRepository.isOnBranch方法的典型用法代码示例。如果您正苦于以下问题:Java GitRepository.isOnBranch方法的具体用法?Java GitRepository.isOnBranch怎么用?Java GitRepository.isOnBranch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git4idea.repo.GitRepository
的用法示例。
在下文中一共展示了GitRepository.isOnBranch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDetachedRoot
import git4idea.repo.GitRepository; //导入方法依赖的package包/类
/**
* Scans the Git roots, selected for commit, for the root which is on a detached HEAD.
* Returns null, if all repositories are on the branch.
* There might be several detached repositories, - in that case only one is returned.
* This is because the situation is very rare, while it requires a lot of additional effort of making a well-formed message.
*/
@Nullable
private DetachedRoot getDetachedRoot() {
GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(myPanel.getProject());
for (VirtualFile root : getSelectedRoots()) {
GitRepository repository = repositoryManager.getRepositoryForRoot(root);
if (repository == null) {
continue;
}
if (!repository.isOnBranch()) {
return new DetachedRoot(root, repository.isRebaseInProgress());
}
}
return null;
}
示例2: noBranchesToCompare
import git4idea.repo.GitRepository; //导入方法依赖的package包/类
private static boolean noBranchesToCompare(@NotNull GitRepository repository) {
int locals = repository.getBranches().getLocalBranches().size();
boolean haveRemotes = !repository.getBranches().getRemoteBranches().isEmpty();
if (repository.isOnBranch()) { // there are other branches to compare
return locals < 2 && !haveRemotes;
}
return locals == 0 && !haveRemotes; // there are at least 1 branch to compare
}