Search in sources :

Example 11 with GitRepository

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;
}
Also used : GitRepository(git4idea.repo.GitRepository)

Example 12 with GitRepository

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);
            }
        });
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GitRebaseDialog(git4idea.rebase.GitRebaseDialog)

Example 13 with GitRepository

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;
}
Also used : GitRepository(git4idea.repo.GitRepository)

Example 14 with GitRepository

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;
}
Also used : GitRepository(git4idea.repo.GitRepository) GitRepositoryManager(git4idea.repo.GitRepositoryManager) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with GitRepository

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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) Function(com.intellij.util.Function) GitRepository(git4idea.repo.GitRepository) GitRepositoryManager(git4idea.repo.GitRepositoryManager) Nullable(org.jetbrains.annotations.Nullable) NotNull(org.jetbrains.annotations.NotNull) ObjectUtils.assertNotNull(com.intellij.util.ObjectUtils.assertNotNull)

Aggregations

GitRepository (git4idea.repo.GitRepository)123 VirtualFile (com.intellij.openapi.vfs.VirtualFile)46 NotNull (org.jetbrains.annotations.NotNull)33 Nullable (org.jetbrains.annotations.Nullable)19 Project (com.intellij.openapi.project.Project)18 GitCommandResult (git4idea.commands.GitCommandResult)14 GitRepositoryManager (git4idea.repo.GitRepositoryManager)12 VcsException (com.intellij.openapi.vcs.VcsException)11 AccessToken (com.intellij.openapi.application.AccessToken)9 File (java.io.File)8 Map (java.util.Map)8 GitRemote (git4idea.repo.GitRemote)7 FilePath (com.intellij.openapi.vcs.FilePath)6 Change (com.intellij.openapi.vcs.changes.Change)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 Task (com.intellij.openapi.progress.Task)5 ArrayList (java.util.ArrayList)5 ObjectUtils.assertNotNull (com.intellij.util.ObjectUtils.assertNotNull)4 MultiMap (com.intellij.util.containers.MultiMap)4 GitBranch (git4idea.GitBranch)4