mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-92750 handle exceptions in case of incorrect git output
This commit is contained in:
@@ -140,14 +140,15 @@ public class GitPullDialog extends DialogWrapper {
|
||||
});
|
||||
|
||||
if (!result.isNull() && result.get().success()) {
|
||||
return ContainerUtil.mapNotNull(result.get().getOutput(), new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(@NotNull String line) {
|
||||
if (StringUtil.isEmptyOrSpaces(line)) return null;
|
||||
String shortRemoteName = line.trim().substring(line.indexOf(GitBranch.REFS_HEADS_PREFIX) + GitBranch.REFS_HEADS_PREFIX.length());
|
||||
return remote.getName() + "/" + shortRemoteName;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return parseRemoteBranches(remote, result.get().getOutput());
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Couldn't parse ls-remote output: [" + result.get().getOutput() + "]", e);
|
||||
Messages.showErrorDialog(this.getRootPane(), "Couldn't parse ls-remote output",
|
||||
"Couldn't get the remote branches list from " + remote.getName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
String message = result.isNull() ? "" : result.get().getErrorOutputAsJoinedString();
|
||||
@@ -156,6 +157,18 @@ public class GitPullDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<String> parseRemoteBranches(@NotNull final GitRemote remote, @NotNull List<String> lsRemoteOutputLines) {
|
||||
return ContainerUtil.mapNotNull(lsRemoteOutputLines, new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(@NotNull String line) {
|
||||
if (StringUtil.isEmptyOrSpaces(line)) return null;
|
||||
String shortRemoteName = line.trim().substring(line.indexOf(GitBranch.REFS_HEADS_PREFIX) + GitBranch.REFS_HEADS_PREFIX.length());
|
||||
return remote.getName() + "/" + shortRemoteName;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void validateDialog() {
|
||||
String selectedRemote = getRemote();
|
||||
if (StringUtil.isEmptyOrSpaces(selectedRemote)) {
|
||||
|
||||
Reference in New Issue
Block a user