use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitRejectedPushUpdateDialog method makeDescription.
private String makeDescription() {
if (GitUtil.justOneGitRepository(myProject)) {
assert !myRepositories.isEmpty() : "repositories are empty";
GitRepository repository = myRepositories.iterator().next();
GitBranch currentBranch = getCurrentBranch(repository);
return DESCRIPTION_START + code(currentBranch.getName()) + " was rejected. <br/>" + descriptionEnding();
} else if (myRepositories.size() == 1) {
// there are more than 1 repositories in the project, but only one was rejected
GitRepository repository = myRepositories.iterator().next();
GitBranch currentBranch = getCurrentBranch(repository);
return DESCRIPTION_START + code(currentBranch.getName()) + " in repository <br/>" + code(repository.getPresentableUrl()) + " was rejected. <br/>" + descriptionEnding();
} else {
// several repositories rejected the push
Map<GitRepository, GitBranch> currentBranches = getCurrentBranches();
if (allBranchesHaveTheSameName(currentBranches)) {
String branchName = currentBranches.values().iterator().next().getName();
StringBuilder sb = new StringBuilder(DESCRIPTION_START + code(branchName) + " was rejected in repositories <br/>");
for (GitRepository repository : DvcsUtil.sortRepositories(currentBranches.keySet())) {
sb.append(HTML_IDENT).append(code(repository.getPresentableUrl())).append("<br/>");
}
sb.append(descriptionEnding());
return sb.toString();
} else {
StringBuilder sb = new StringBuilder("<html>Push of current branch was rejected: <br/>");
for (Map.Entry<GitRepository, GitBranch> entry : currentBranches.entrySet()) {
GitRepository repository = entry.getKey();
GitBranch currentBranch = entry.getValue();
sb.append(HTML_IDENT + code(currentBranch.getName()) + " in " + code(repository.getPresentableUrl()) + "<br/>");
}
sb.append(descriptionEnding());
return sb.toString();
}
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchesAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
GitRepository repository = file == null ? GitBranchUtil.getCurrentRepository(project) : GitBranchUtil.getRepositoryOrGuess(project, file);
if (repository != null) {
GitBranchPopup.getInstance(project, repository).asListPopup().showCenteredInCurrentWindow(project);
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class CloudGitProjectStructureDetector method detectApplicationRoot.
private static void detectApplicationRoot(@NotNull File dir, @NotNull List<DetectedProjectRoot> result) {
VirtualFile repositoryRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
if (repositoryRoot == null) {
return;
}
if (GitUtil.findGitDir(repositoryRoot) == null) {
return;
}
Project project = ProjectManager.getInstance().getDefaultProject();
GitRepository repository = GitRepositoryImpl.getInstance(repositoryRoot, project, false);
for (CloudGitDeploymentDetector deploymentDetector : CloudGitDeploymentDetector.EP_NAME.getExtensions()) {
String applicationName = deploymentDetector.getFirstApplicationName(repository);
if (applicationName != null) {
result.add(new CloudGitProjectRoot(deploymentDetector, dir, repositoryRoot, applicationName));
}
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitRepositoryForAnnotationsListener method createListener.
private GitRepositoryChangeListener createListener() {
return new GitRepositoryChangeListener() {
@Override
public void repositoryChanged(@NotNull GitRepository repository) {
final VcsAnnotationRefresher refresher = myProject.getMessageBus().syncPublisher(VcsAnnotationRefresher.LOCAL_CHANGES_CHANGED);
refresher.dirtyUnder(repository.getRoot());
}
};
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchUtil method getCurrentBranchOrRev.
@NotNull
static String getCurrentBranchOrRev(@NotNull Collection<GitRepository> repositories) {
if (repositories.size() > 1) {
GitMultiRootBranchConfig multiRootBranchConfig = new GitMultiRootBranchConfig(repositories);
String currentBranch = multiRootBranchConfig.getCurrentBranch();
LOG.assertTrue(currentBranch != null, "Repositories have unexpectedly diverged. " + multiRootBranchConfig);
return currentBranch;
} else {
assert !repositories.isEmpty() : "No repositories passed to GitBranchOperationsProcessor.";
GitRepository repository = repositories.iterator().next();
return getBranchNameOrRev(repository);
}
}
Aggregations