Search in sources :

Example 11 with GitRemote

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

the class GitFetcher method fetchAll.

@NotNull
private static GitFetchResult fetchAll(@NotNull GitRepository repository) {
    GitFetchResult fetchResult = GitFetchResult.success();
    for (GitRemote remote : repository.getRemotes()) {
        String url = remote.getFirstUrl();
        if (url == null) {
            LOG.error("URL is null for remote " + remote.getName());
            continue;
        }
        GitFetchResult res = fetchNatively(repository, remote, null);
        res.addPruneInfo(fetchResult.getPrunedRefs());
        fetchResult = res;
        if (!fetchResult.isSuccess()) {
            break;
        }
    }
    return fetchResult;
}
Also used : GitRemote(git4idea.repo.GitRemote) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with GitRemote

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

the class GitPushResultNotificationTest method to.

private static GitRemoteBranch to(String to) {
    int firstSlash = to.indexOf('/');
    GitRemote remote = new GitRemote(to.substring(0, firstSlash), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    return new GitStandardRemoteBranch(remote, to.substring(firstSlash + 1));
}
Also used : GitRemote(git4idea.repo.GitRemote) GitStandardRemoteBranch(git4idea.GitStandardRemoteBranch)

Example 13 with GitRemote

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

the class GitFetcher method fetchCurrentBranch.

// leaving this unused method, because the wanted behavior can change again
@SuppressWarnings("UnusedDeclaration")
@NotNull
private GitFetchResult fetchCurrentBranch(@NotNull GitRepository repository) {
    FetchParams fetchParams = getFetchParams(repository);
    if (fetchParams.isError()) {
        return fetchParams.getError();
    }
    GitRemote remote = fetchParams.getRemote();
    String remoteBranch = fetchParams.getRemoteBranch().getNameForRemoteOperations();
    return fetchNatively(repository, remote, remoteBranch);
}
Also used : GitRemote(git4idea.repo.GitRemote) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with GitRemote

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

the class GitFetcher method fetchCurrentRemote.

@NotNull
private GitFetchResult fetchCurrentRemote(@NotNull GitRepository repository) {
    FetchParams fetchParams = getFetchParams(repository);
    if (fetchParams.isError()) {
        return fetchParams.getError();
    }
    GitRemote remote = fetchParams.getRemote();
    return fetchRemote(repository, remote, null);
}
Also used : GitRemote(git4idea.repo.GitRemote) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with GitRemote

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

the class GitBranchUtil method tracked.

/**
   * Get the tracking branch for the given branch, or null if the given branch doesn't track anything.
   * @deprecated Use {@link GitConfig#getBranchTrackInfos()}
   */
@Deprecated
@Nullable
public static GitRemoteBranch tracked(@NotNull Project project, @NotNull VirtualFile root, @NotNull String branchName) throws VcsException {
    final HashMap<String, String> result = new HashMap<>();
    GitConfigUtil.getValues(project, root, null, result);
    String remoteName = result.get(trackedRemoteKey(branchName));
    if (remoteName == null) {
        return null;
    }
    String branch = result.get(trackedBranchKey(branchName));
    if (branch == null) {
        return null;
    }
    if (".".equals(remoteName)) {
        return new GitSvnRemoteBranch(branch);
    }
    GitRemote remote = findRemoteByNameOrLogError(project, root, remoteName);
    if (remote == null)
        return null;
    return new GitStandardRemoteBranch(remote, branch);
}
Also used : GitRemote(git4idea.repo.GitRemote) HashMap(java.util.HashMap) Nullable(org.jetbrains.annotations.Nullable)

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