mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-152241 don't fail if couldn't load commits for a branch
This can happen for various reasons, e.g. if the branch doesn't have an upstream in one of remaining repositories. No need to fail everything in those cases. Also inline the history() method: it doesn't conform to other Git api methods.
This commit is contained in:
@@ -18,11 +18,13 @@ package git4idea.branch;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import git4idea.GitCommit;
|
||||
import git4idea.commands.*;
|
||||
import git4idea.history.GitHistoryUtils;
|
||||
import git4idea.repo.GitRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,6 +33,8 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.intellij.dvcs.DvcsUtil.getShortRepositoryName;
|
||||
|
||||
/**
|
||||
* Deletes a branch.
|
||||
* If branch is not fully merged to the current branch, shows a dialog with the list of unmerged commits and with a list of branches
|
||||
@@ -182,8 +186,17 @@ class GitDeleteBranchOperation extends GitBranchOperation {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<GitCommit> getUnmergedCommits(@NotNull GitRepository repository, @NotNull String branchName, @NotNull String baseBranch) {
|
||||
return myGit.history(repository, baseBranch + ".." + branchName);
|
||||
private static List<GitCommit> getUnmergedCommits(@NotNull GitRepository repository,
|
||||
@NotNull String branchName,
|
||||
@NotNull String baseBranch) {
|
||||
String range = baseBranch + ".." + branchName;
|
||||
try {
|
||||
return GitHistoryUtils.history(repository.getProject(), repository.getRoot(), range);
|
||||
}
|
||||
catch (VcsException e) {
|
||||
LOG.warn("Couldn't get `git log " + range + "` in " + getShortRepositoryName(repository), e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -152,9 +152,6 @@ public interface Git {
|
||||
@NotNull
|
||||
GitCommandResult stashPop(@NotNull GitRepository repository, @NotNull GitLineHandlerListener... listeners);
|
||||
|
||||
@NotNull
|
||||
List<GitCommit> history(@NotNull GitRepository repository, @NotNull String range);
|
||||
|
||||
@NotNull
|
||||
GitCommandResult fetch(@NotNull GitRepository repository,
|
||||
@NotNull GitRemote remote,
|
||||
|
||||
@@ -29,12 +29,9 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.vcsUtil.VcsFileUtil;
|
||||
import git4idea.GitCommit;
|
||||
import git4idea.GitExecutionException;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.branch.GitRebaseParams;
|
||||
import git4idea.config.GitVersionSpecialty;
|
||||
import git4idea.history.GitHistoryUtils;
|
||||
import git4idea.rebase.GitInteractiveRebaseEditorHandler;
|
||||
import git4idea.rebase.GitRebaseEditorService;
|
||||
import git4idea.rebase.GitRebaseResumeMode;
|
||||
@@ -224,18 +221,6 @@ public class GitImpl implements Git {
|
||||
return run(handler);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<GitCommit> history(@NotNull GitRepository repository, @NotNull String range) {
|
||||
try {
|
||||
return GitHistoryUtils.history(repository.getProject(), repository.getRoot(), range);
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// this is critical, because we need to show the list of unmerged commits, and it shouldn't happen => inform user and developer
|
||||
throw new GitExecutionException("Couldn't get [git log " + range + "] on repository [" + repository.getRoot() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public GitCommandResult merge(@NotNull GitRepository repository, @NotNull String branchToMerge,
|
||||
|
||||
Reference in New Issue
Block a user