Search in sources :

Example 1 with VcsError

use of com.intellij.dvcs.push.VcsError in project intellij-community by JetBrains.

the class GitOutgoingCommitsProvider method getOutgoingCommits.

@NotNull
@Override
public OutgoingResult getOutgoingCommits(@NotNull GitRepository repository, @NotNull PushSpec<GitPushSource, GitPushTarget> pushSpec, boolean initial) {
    GitLocalBranch branch = pushSpec.getSource().getBranch();
    String source = branch.equals(repository.getCurrentBranch()) ? HEAD : branch.getFullName();
    GitPushTarget target = pushSpec.getTarget();
    String destination = target.getBranch().getFullName();
    try {
        List<GitCommit> commits;
        if (!target.isNewBranchCreated()) {
            commits = GitHistoryUtils.history(myProject, repository.getRoot(), destination + ".." + source);
        } else {
            commits = GitHistoryUtils.history(myProject, repository.getRoot(), source, "--not", "--remotes=" + target.getBranch().getRemote().getName(), "--max-count=" + 1000);
        }
        return new OutgoingResult(commits, Collections.<VcsError>emptyList());
    } catch (VcsException e) {
        return new OutgoingResult(Collections.<VcsFullCommitDetails>emptyList(), Collections.singletonList(new VcsError(GitUtil.cleanupErrorPrefixes(e.getMessage()))));
    }
}
Also used : GitLocalBranch(git4idea.GitLocalBranch) GitCommit(git4idea.GitCommit) VcsException(com.intellij.openapi.vcs.VcsException) OutgoingResult(com.intellij.dvcs.push.OutgoingResult) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails) VcsError(com.intellij.dvcs.push.VcsError) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

OutgoingResult (com.intellij.dvcs.push.OutgoingResult)1 VcsError (com.intellij.dvcs.push.VcsError)1 VcsException (com.intellij.openapi.vcs.VcsException)1 VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)1 GitCommit (git4idea.GitCommit)1 GitLocalBranch (git4idea.GitLocalBranch)1 NotNull (org.jetbrains.annotations.NotNull)1