Search in sources :

Example 1 with GitRemote

use of git4idea.repo.GitRemote in project intellij-community by JetBrains.

the class GitBranchUtil method findRemoteByNameOrLogError.

@Nullable
@Deprecated
public static GitRemote findRemoteByNameOrLogError(@NotNull Project project, @NotNull VirtualFile root, @NotNull String remoteName) {
    GitRepository repository = GitUtil.getRepositoryForRootOrLogError(project, root);
    if (repository == null) {
        return null;
    }
    GitRemote remote = GitUtil.findRemoteByName(repository, remoteName);
    if (remote == null) {
        LOG.warn("Couldn't find remote with name " + remoteName);
        return null;
    }
    return remote;
}
Also used : GitRemote(git4idea.repo.GitRemote) GitRepository(git4idea.repo.GitRepository) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GitRemote

use of git4idea.repo.GitRemote in project intellij-community by JetBrains.

the class CloudGitDeploymentRuntime method addOrResetGitRemote.

public void addOrResetGitRemote(CloudGitApplication application, GitRepository repository) throws ServerRuntimeException {
    String gitUrl = application.getGitUrl();
    if (myRemoteName == null) {
        for (GitRemote gitRemote : repository.getRemotes()) {
            if (gitRemote.getUrls().contains(gitUrl)) {
                myRemoteName = gitRemote.getName();
                return;
            }
        }
    }
    GitRemote gitRemote = GitUtil.findRemoteByName(repository, getRemoteName());
    if (gitRemote == null) {
        addGitRemote(application);
    } else if (!gitRemote.getUrls().contains(gitUrl)) {
        resetGitRemote(application);
    }
}
Also used : GitRemote(git4idea.repo.GitRemote)

Example 3 with GitRemote

use of git4idea.repo.GitRemote in project intellij-community by JetBrains.

the class GitDeleteRemoteBranchOperation method doDeleteRemote.

private boolean doDeleteRemote(@NotNull String branchName, @NotNull Collection<GitRepository> repositories) {
    Couple<String> pair = splitNameOfRemoteBranch(branchName);
    String remoteName = pair.getFirst();
    String branch = pair.getSecond();
    GitCompoundResult result = new GitCompoundResult(myProject);
    for (GitRepository repository : repositories) {
        GitCommandResult res;
        GitRemote remote = getRemoteByName(repository, remoteName);
        if (remote == null) {
            String error = "Couldn't find remote by name: " + remoteName;
            LOG.error(error);
            res = GitCommandResult.error(error);
        } else {
            res = pushDeletion(repository, remote, branch);
            if (!res.success() && isAlreadyDeletedError(res.getErrorOutputAsJoinedString())) {
                res = myGit.remotePrune(repository, remote);
            }
        }
        result.append(repository, res);
        repository.update();
    }
    if (!result.totalSuccess()) {
        VcsNotifier.getInstance(myProject).notifyError("Failed to delete remote branch " + branchName, result.getErrorOutputWithReposIndication());
    }
    return result.totalSuccess();
}
Also used : GitRemote(git4idea.repo.GitRemote) GitCompoundResult(git4idea.commands.GitCompoundResult) GitRepository(git4idea.repo.GitRepository) GitCommandResult(git4idea.commands.GitCommandResult)

Example 4 with GitRemote

use of git4idea.repo.GitRemote in project intellij-community by JetBrains.

the class GitVcsSettings method getPushTarget.

@Nullable
public GitRemoteBranch getPushTarget(@NotNull GitRepository repository, @NotNull String sourceBranch) {
    PushTargetInfo targetInfo = find(myState.PUSH_TARGETS, repository, sourceBranch);
    if (targetInfo == null)
        return null;
    GitRemote remote = GitUtil.findRemoteByName(repository, targetInfo.targetRemoteName);
    if (remote == null)
        return null;
    return GitUtil.findOrCreateRemoteBranch(repository, remote, targetInfo.targetBranchName);
}
Also used : GitRemote(git4idea.repo.GitRemote) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with GitRemote

use of git4idea.repo.GitRemote in project intellij-community by JetBrains.

the class GitRefManager method getAllRemoteBranches.

@NotNull
private static Map<String, GitRemote> getAllRemoteBranches(@NotNull GitRepository repository) {
    Set<GitRemoteBranch> all = new HashSet<>(repository.getBranches().getRemoteBranches());
    Map<String, GitRemote> allRemote = ContainerUtil.newHashMap();
    for (GitRemoteBranch remoteBranch : all) {
        allRemote.put(remoteBranch.getName(), remoteBranch.getRemote());
    }
    return allRemote;
}
Also used : GitRemote(git4idea.repo.GitRemote) GitRemoteBranch(git4idea.GitRemoteBranch) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GitRemote (git4idea.repo.GitRemote)22 NotNull (org.jetbrains.annotations.NotNull)8 GitRepository (git4idea.repo.GitRepository)7 Nullable (org.jetbrains.annotations.Nullable)7 GitRemoteBranch (git4idea.GitRemoteBranch)3 GitBranchTrackInfo (git4idea.repo.GitBranchTrackInfo)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 SimpleRefGroup (com.intellij.vcs.log.impl.SimpleRefGroup)2 GitLocalBranch (git4idea.GitLocalBranch)2 GitStandardRemoteBranch (git4idea.GitStandardRemoteBranch)2 Computable (com.intellij.openapi.util.Computable)1 VcsException (com.intellij.openapi.vcs.VcsException)1 MultiMap (com.intellij.util.containers.MultiMap)1 SingletonRefGroup (com.intellij.vcs.log.impl.SingletonRefGroup)1 Git (git4idea.commands.Git)1 GitCommandResult (git4idea.commands.GitCommandResult)1 GitCompoundResult (git4idea.commands.GitCompoundResult)1 GitLineHandler (git4idea.commands.GitLineHandler)1 GitPullDialog (git4idea.merge.GitPullDialog)1 GitRepositoryManager (git4idea.repo.GitRepositoryManager)1