use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCheckoutOperation method checkoutOrNotify.
/**
* Checks out or shows an error message.
*/
private boolean checkoutOrNotify(@NotNull List<GitRepository> repositories, @NotNull String reference, @Nullable String newBranch, boolean force) {
GitCompoundResult compoundResult = new GitCompoundResult(myProject);
for (GitRepository repository : repositories) {
compoundResult.append(repository, myGit.checkout(repository, reference, newBranch, force, myDetach));
}
if (compoundResult.totalSuccess()) {
return true;
}
notifyError("Couldn't checkout " + reference, compoundResult.getErrorOutputWithReposIndication());
return false;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitRebase method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
ArrayList<GitRepository> repositories = ContainerUtil.newArrayList(getRepositories(project));
repositories.removeAll(getRebasingRepositories(project));
List<VirtualFile> roots = ContainerUtil.newArrayList(getRootsFromRepositories(sortRepositories(repositories)));
VirtualFile defaultRoot = DvcsUtil.guessVcsRoot(project, e.getData(CommonDataKeys.VIRTUAL_FILE));
final GitRebaseDialog dialog = new GitRebaseDialog(project, roots, defaultRoot);
if (dialog.showAndGet()) {
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Rebasing...") {
public void run(@NotNull ProgressIndicator indicator) {
GitRebaseUtils.rebase(project, singletonList(dialog.getSelectedRepository()), dialog.getSelectedParams(), indicator);
}
});
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class CloudGitDeploymentRuntime method findOrCreateRepository.
public GitRepository findOrCreateRepository() throws ServerRuntimeException {
GitRepository repository = findRepository();
if (repository == null) {
getLoggingHandler().println("Initializing git repository...");
GitCommandResult gitInitResult = getGit().init(getProject(), getRepositoryRoot(), createGitLineHandlerListener());
checkGitResult(gitInitResult);
refreshApplicationRepository();
repository = getRepository();
}
return repository;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitUtil method getRepositoryForRootOrLogError.
@Nullable
public static GitRepository getRepositoryForRootOrLogError(@NotNull Project project, @NotNull VirtualFile root) {
GitRepositoryManager manager = getRepositoryManager(project);
GitRepository repository = manager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository is null for root " + root);
}
return repository;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitUtil method getRepositoriesForFiles.
@NotNull
public static Collection<GitRepository> getRepositoriesForFiles(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
final GitRepositoryManager manager = getRepositoryManager(project);
com.google.common.base.Function<VirtualFile, GitRepository> ROOT_TO_REPO = new com.google.common.base.Function<VirtualFile, GitRepository>() {
@Override
public GitRepository apply(@Nullable VirtualFile root) {
return root != null ? manager.getRepositoryForRoot(root) : null;
}
};
return Collections2.filter(Collections2.transform(sortFilesByGitRootsIgnoringOthers(files).keySet(), ROOT_TO_REPO), Predicates.notNull());
}
Aggregations